BuyTicket.cshtml 103 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843
  1. @model LotteryWebApp.Models.HomeIndex_ViewModel
  2. @{
  3. ViewData["Title"] = "Millions - Buy Ticket";
  4. Layout = "~/Areas/Millions/Views/Shared/_Layout.cshtml";
  5. var currentTerm = Model.listTerm?.FirstOrDefault();
  6. }
  7. @using LotteryWebApp.Languages;
  8. @using LotteryWebApp.Common;
  9. @using Microsoft.AspNetCore.Http;
  10. @{
  11. var isFreeTicketMode = Context.Request.Query["freeTicketMode"] == "1"
  12. && Model.termType == Constants.Millions_CODE;
  13. var freeTicketPromotionCode = isFreeTicketMode
  14. ? Context.Session.GetString("Millions.FreeTicket.PromotionCode")
  15. : null;
  16. var hasFreeTicketPromotion = isFreeTicketMode
  17. && !string.IsNullOrWhiteSpace(freeTicketPromotionCode);
  18. }
  19. @section Styles {
  20. <link rel="stylesheet" href="/Millions/css/buy-ticket.css" asp-append-version="true" />
  21. <style>
  22. /* BuyTicket has its own bottom bar; avoid global navbar padding gap */
  23. body.millions-bg { padding-bottom: 0 !important; }
  24. body.millions-bg .main-container { padding-bottom: 0 !important; }
  25. </style>
  26. }
  27. @if (Model.termType == Constants.PIC10_BIGSMALL_CODE || Model.termType == Constants.PIC10_ODDEVEN_CODE)
  28. {
  29. var isBigSmall = Model.termType == Constants.PIC10_BIGSMALL_CODE;
  30. var themeColor = isBigSmall ? "#0A9800" : "#AA3DC8";
  31. var gameTitle = isBigSmall ? Lang.millions_big_small : Lang.millions_odd_even;
  32. var prizeAmount = isBigSmall ? "100.000" : "200.000";
  33. <!-- ====== CARD SELECTION GAME UI (BIG/SMALL or ODD/EVEN) ====== -->
  34. <div class="millions-buy-ticket-page main-container animate__animated animate__fadeIn overflow-hidden">
  35. <!-- Header -->
  36. <div class="header">
  37. <button onclick="location.href='@Url.Action("GameHome", "Home")'" class="back-btn" type="button">
  38. <i class="fa-solid fa-arrow-left"></i>
  39. </button>
  40. <div class="header-title">@gameTitle</div>
  41. </div>
  42. <div class="content-card">
  43. <!-- Sticky Term Info sub-header -->
  44. <div class="ticket-subheader">
  45. <div class="flex items-center justify-between">
  46. <div class="flex items-center gap-2 border border-[#E5E7EB] rounded-lg px-3 py-1.5 bg-gray-50">
  47. <i class="fa-regular fa-calendar text-[[@themeColor]] text-sm" style="color: @themeColor"></i>
  48. <span class="text-[12px] font-bold text-gray-700">@DateTime.Now.ToString("dddd, MMM dd, yyyy", new System.Globalization.CultureInfo("en-US"))</span>
  49. </div>
  50. <div class="flex items-center gap-1 ml-4 flex-1 justify-end">
  51. <span class="text-[12px] font-bold text-gray-400">@Lang.millions_round</span>
  52. <span class="text-[18px] font-black text-brown-main">#@(currentTerm?.id ?? "123")</span>
  53. </div>
  54. </div>
  55. </div>
  56. <!-- Scrollable Content Area -->
  57. <div class="ticket-scroll-area bg-white pb-40" id="bsContent">
  58. <!-- Results for the last 5 days -->
  59. <div class="px-5 pt-4 pb-2">
  60. <h3 class="text-[17px] font-bold text-black text-center mb-3">Results for the last 5 days</h3>
  61. <div id="last5Results" class="flex justify-between gap-1.5 px-1">
  62. @{
  63. var pastTerms = ViewBag.PastTerms as List<LotteryWebApp.Service.Term> ?? new List<LotteryWebApp.Service.Term>();
  64. foreach (var term in pastTerms) {
  65. var rawResult = (term.result ?? "").Trim().ToUpper();
  66. var dateStr = "--";
  67. DateTime dt;
  68. if (DateTime.TryParse(term.date_random, out dt)) {
  69. dateStr = dt.ToString("MMM dd", new System.Globalization.CultureInfo("en-US"));
  70. }
  71. var resKey = rawResult;
  72. var resTitle = rawResult;
  73. if (isBigSmall) {
  74. if (rawResult == "S") { resKey = "Small"; resTitle = Lang.Small; }
  75. else if (rawResult == "B") { resKey = "Big"; resTitle = Lang.Big; }
  76. } else {
  77. if (rawResult == "O") { resKey = "Odd"; resTitle = Lang.Odd; }
  78. else if (rawResult == "E") { resKey = "Even"; resTitle = Lang.Even; }
  79. }
  80. var resColor = "";
  81. var bgStyle = "background: linear-gradient(136deg, #FFFAE6 0%, #FFE588 100%);";
  82. var textStyle = "-webkit-text-stroke: 0.5px #000;";
  83. if (resKey == "NA" || string.IsNullOrEmpty(rawResult)) {
  84. bgStyle = "background: #EAEAEA;";
  85. resTitle = "";
  86. textStyle = "";
  87. } else {
  88. if (isBigSmall) {
  89. resColor = resKey == "Big" ? "#A2FF00" : "#FF4157";
  90. } else {
  91. resColor = resKey == "Odd" ? "#FFC700" : "#B33BD0";
  92. }
  93. textStyle += $" color: {resColor};";
  94. }
  95. <div class="flex flex-col items-center justify-center min-h-[64px] flex-1 rounded-lg py-1.5 border border-gray-200" style="@bgStyle">
  96. <span class="text-[11px] font-bold text-black whitespace-nowrap opacity-70">@dateStr</span>
  97. <span class="text-[22px] font-black leading-tight" style="@textStyle">@resTitle</span>
  98. </div>
  99. }
  100. for(int r = pastTerms.Count; r < 5; r++) {
  101. <div class="flex flex-col items-center justify-center min-h-[64px] flex-1 rounded-lg py-1.5 border border-gray-200" style="background: #EAEAEA; opacity: 0.7;">
  102. <span class="text-[11px] font-bold text-black whitespace-nowrap opacity-70">--</span>
  103. <span class="text-[22px] font-black leading-tight" style="color: transparent;"></span>
  104. </div>
  105. }
  106. }
  107. </div>
  108. </div>
  109. <!-- Selection Cards -->
  110. <!-- Selection Cards -->
  111. <div class="px-5 pt-4 flex gap-3 h-[245px]">
  112. <!-- Card 1 (Big or Odd) -->
  113. <div id="cardBig" onclick="selectBigSmall('big')" class="bigsmall-card flex-1 rounded-2xl relative cursor-pointer transition-all duration-300 active:scale-[0.97] border-2 border-transparent overflow-hidden flex flex-col" style="background: linear-gradient(180deg, #FFF7DB 0%, #FFEEB3 100%);">
  114. <img src="/Millions/img/bigsmall/light_effect_1.png" class="absolute top-0 left-0 w-full opacity-60 pointer-events-none" alt="" />
  115. <img src="/Millions/img/bigsmall/light_effect_2.png" class="absolute bottom-12 left-0 w-full opacity-60 pointer-events-none" alt="" />
  116. <div class="flex flex-col items-center pt-4 pb-3 px-3 relative z-10 h-full justify-between">
  117. <div class="flex flex-col items-center w-full">
  118. <div class="h-[34px] flex items-center justify-center">
  119. <div class="text-[40px] font-[800] leading-none" style="-webkit-text-stroke: 1px #000; text-shadow: 1px 2px 2px rgba(0,0,0,0.15); color: @(isBigSmall ? "#A2FF00" : "#FFC700");">@(isBigSmall ? "Big" : "Odd")</div>
  120. </div>
  121. <div class="text-[11px] font-medium text-gray-500 mt-1 h-[28px] text-center leading-tight">
  122. @(isBigSmall ? "13 number from" : "Odd numbers") <br/> <b>@(isBigSmall ? "41-80" : "1, 3, 5, 7, 9")</b>
  123. </div>
  124. </div>
  125. <div class="flex items-center justify-center -space-x-2 my-2">
  126. @if (isBigSmall) {
  127. <img src="/Millions/img/bigsmall/ball_42_dark.png" class="w-12 h-12 relative z-[1]" alt="42" />
  128. <img src="/Millions/img/bigsmall/ball_88_big.png" class="w-16 h-16 relative z-[2]" alt="88" />
  129. <img src="/Millions/img/bigsmall/ball_54_dark.png" class="w-12 h-12 relative z-[1]" alt="54" />
  130. } else {
  131. <img src="/Millions/img/oddeven/ball_3.png" class="w-12 h-12 relative z-[1]" alt="3" />
  132. <img src="/Millions/img/oddeven/ball_1.png" class="w-16 h-16 relative z-[2]" alt="1" />
  133. <img src="/Millions/img/oddeven/ball_19.png" class="w-12 h-12 relative z-[1]" alt="19" />
  134. }
  135. </div>
  136. <button class="bigsmall-btn w-full py-2.5 rounded-xl font-black text-[15px] transition-all shadow-md" style="background: @themeColor; color: white;">@Lang.millions_select</button>
  137. </div>
  138. </div>
  139. <!-- Card 2 (Small or Even) -->
  140. <div id="cardSmall" onclick="selectBigSmall('small')" class="bigsmall-card flex-1 rounded-2xl relative cursor-pointer transition-all duration-300 active:scale-[0.97] border-2 border-transparent overflow-hidden flex flex-col" style="background: linear-gradient(180deg, #FFF7DB 0%, #FFEEB3 100%);">
  141. <img src="/Millions/img/bigsmall/light_effect_1.png" class="absolute top-0 left-0 w-full opacity-60 pointer-events-none" alt="" />
  142. <img src="/Millions/img/bigsmall/light_effect_2.png" class="absolute bottom-12 left-0 w-full opacity-60 pointer-events-none" alt="" />
  143. <div class="flex flex-col items-center pt-4 pb-3 px-3 relative z-10 h-full justify-between">
  144. <div class="flex flex-col items-center w-full">
  145. <div class="h-[34px] flex items-center justify-center">
  146. <div class="text-[40px] font-[800] leading-none italic" style="-webkit-text-stroke: 1px #000; text-shadow: 1px 2px 2px rgba(0,0,0,0.15); color: @(isBigSmall ? "#FF4157" : "#B33BD0");">@(isBigSmall ? "Small" : "Even")</div>
  147. </div>
  148. <div class="text-[11px] font-medium text-gray-500 mt-1 h-[28px] text-center leading-tight">
  149. @(isBigSmall ? "13 number from" : "Even numbers") <br/> <b>@(isBigSmall ? "01-40" : "0, 2, 4, 6, 8")</b>
  150. </div>
  151. </div>
  152. <div class="flex items-center justify-center -space-x-2 my-2">
  153. @if (isBigSmall) {
  154. <img src="/Millions/img/bigsmall/ball_5_blue.png" class="w-12 h-12 relative z-[1]" alt="5" />
  155. <img src="/Millions/img/bigsmall/ball_1_big.png" class="w-16 h-16 relative z-[2]" alt="1" />
  156. <img src="/Millions/img/bigsmall/ball_8_pink.png" class="w-12 h-12 relative z-[1]" alt="8" />
  157. } else {
  158. <img src="/Millions/img/oddeven/ball_66.png" class="w-12 h-12 relative z-[1]" alt="66" />
  159. <img src="/Millions/img/oddeven/ball_68.png" class="w-16 h-16 relative z-[2]" alt="68" />
  160. <img src="/Millions/img/oddeven/ball_88.png" class="w-12 h-12 relative z-[1]" alt="88" />
  161. }
  162. </div>
  163. <button class="bigsmall-btn w-full py-2.5 rounded-xl font-black text-[15px] transition-all shadow-md"
  164. style="background: @themeColor; color: white;">@Lang.millions_select</button>
  165. </div>
  166. </div>
  167. </div>
  168. <!-- You Choose + Prize Section -->
  169. <div class="px-5 pt-6 flex flex-col items-center gap-4">
  170. <div class="flex flex-col items-center">
  171. <span class="text-[15px] font-medium text-black">@Lang.millions_you_choose</span>
  172. <span id="choiceDisplay" class="text-[42px] font-[800] leading-tight" style="-webkit-text-stroke: 1px #000;">—</span>
  173. </div>
  174. <div class="flex flex-col items-center">
  175. <span class="text-[18px] font-medium text-black">@Lang.millions_prize_if_win</span>
  176. <div class="flex items-baseline gap-1">
  177. <span class="text-[28px] font-black text-black">@prizeAmount</span>
  178. <span class="text-[14px] font-black text-[#E56B23]">HTG</span>
  179. </div>
  180. </div>
  181. </div>
  182. </div>
  183. <!-- Bottom Action Bar -->
  184. <div class="p-4 bg-white border-t border-gray-200 z-[70] shadow-[0px_-4px_10px_rgba(0,0,0,0.03)] absolute bottom-0 w-full left-0">
  185. <div class="flex items-center justify-between">
  186. <div class="flex flex-col">
  187. <div class="flex items-center gap-1.5 mb-0.5">
  188. <span class="text-[11px] text-black font-black uppercase">@Lang.total_ticket:</span>
  189. <span id="bsTotalTicketCount" class="text-[12px] font-black text-black">0</span>
  190. </div>
  191. <span class="text-[11px] text-black font-black uppercase">@Lang.millions_estimated_ticket_price</span>
  192. <div class="flex items-baseline gap-1">
  193. <span id="bsTotalPrice" class="text-[28px] font-black text-black">0</span>
  194. <span class="text-[13px] font-black" style="color: @themeColor">HTG</span>
  195. </div>
  196. </div>
  197. <button type="button" id="bsPaymentBtn" onpointerdown="armPaymentClick(event)" onkeydown="armPaymentKey(event)" onclick="bsShowPayment(event)" class="text-white text-[20px] font-black px-10 py-3.5 rounded-xl shadow-lg active:scale-95 transition-all" style="background: @themeColor;">
  198. @Lang.millions_payment
  199. </button>
  200. </div>
  201. </div>
  202. </div>
  203. </div>
  204. }
  205. else
  206. {
  207. <!-- ====== Basic Pick 10 / Odd-Even GAME UI ====== -->
  208. <div class="millions-buy-ticket-page main-container animate__animated animate__fadeIn overflow-hidden">
  209. <!-- Header -->
  210. <div class="header">
  211. <button onclick="location.href='@Url.Action("GameHome", "Home")'" class="back-btn" type="button">
  212. <i class="fa-solid fa-arrow-left"></i>
  213. </button>
  214. <div class="header-title">
  215. @if (Model.termType == Constants.PIC10_BASIC_CODE) { <text>Basic Pick 10</text> }
  216. else if (Model.termType == Constants.Millions_CODE) { <text>Millions</text> }
  217. else { @Lang.millions_odd_even }
  218. </div>
  219. </div>
  220. <div class="content-card">
  221. <!-- Sticky Term Info sub-header -->
  222. <div class="ticket-subheader">
  223. <div class="flex items-center justify-between">
  224. <div class="flex items-center gap-2 border border-[#E5E7EB] rounded-lg px-3 py-1.5 bg-gray-50">
  225. <i class="fa-regular fa-calendar text-[#0062FF] text-sm"></i>
  226. <span class="text-[12px] font-bold text-gray-700">@DateTime.Now.ToString("dddd, MMM dd, yyyy", new System.Globalization.CultureInfo("en-US"))</span>
  227. </div>
  228. <div class="flex items-center gap-1 ml-4 flex-1 justify-end">
  229. <span class="text-[12px] font-bold text-gray-400">@Lang.millions_round</span>
  230. <span class="text-[18px] font-black text-brown-main">#@(currentTerm?.id ?? "12459")</span>
  231. </div>
  232. </div>
  233. </div>
  234. <!-- Ticket Scrollable List Area -->
  235. <div id="ticketContainer" class="ticket-scroll-area p-4 flex flex-col gap-6 bg-[#F5F5F5] pb-6">
  236. @for (int i = 1; i <= (isFreeTicketMode ? 1 : 2); i++)
  237. {
  238. <div class="ticket-card relative group active:bg-gray-50 transition-colors cursor-pointer animate__animated animate__fadeIn">
  239. @if (!isFreeTicketMode)
  240. {
  241. <button onclick="removeEntry(this)" class="absolute -right-2 top-2 w-7 h-7 bg-[#FF0000] text-white rounded-full flex items-center justify-center text-[11px] shadow-sm z-[10] hover:bg-red-700 transition-all border-2 border-red-600">
  242. <i class="fa-solid fa-xmark"></i>
  243. </button>
  244. }
  245. <div class="absolute left-2 top-4 w-9 h-9 rounded-full border-[3px] border-white flex items-center justify-center text-white font-black text-sm shadow-md ticket-index">@i</div>
  246. <div class="flex flex-col gap-1 pl-8">
  247. <span class="text-[16px] font-extrabold text-[#333]">@Lang.millions_select_10_lucky_numbers</span>
  248. <div class="flex items-center gap-4">
  249. <div class="grid grid-cols-6 gap-y-2 gap-x-1 flex-1">
  250. @for (int j = 0; j < (Model.termType == Constants.PIC10_BASIC_CODE ? 10 : (Model.termType == Constants.Millions_CODE ? 6 : 15)); j++)
  251. {
  252. var isMbBall = Model.termType == Constants.Millions_CODE && j == 5;
  253. <div class="relative w-fit">
  254. <div class="ball-circle ball-empty@(isMbBall ? " ball-mb-circle" : "")"></div>
  255. @if (isMbBall)
  256. {
  257. <div class="absolute -bottom-[6px] -right-[4px] bg-[#FFD700] text-black text-[8.5px] font-black px-[2.5px] py-[1.5px] rounded-[3px] shadow-sm leading-none z-10 border border-[#EAA800]">MB</div>
  258. }
  259. </div>
  260. }
  261. </div>
  262. <div class="w-[90px] action-area flex flex-col gap-2">
  263. <button onclick="randomizeTicket(this)" class="rand-btn w-full bg-[#2B83F2] text-white flex items-center justify-center gap-1.5 py-1.5 rounded-xl font-extrabold text-[11px] shadow-sm active:scale-95 transition-all">
  264. <i class="fa-solid fa-arrows-rotate text-[10px]"></i> @Lang.Random
  265. </button>
  266. <div class="edit-delete-group hidden flex flex-col gap-2">
  267. <button onclick="editFullTicket(this)" class="w-full bg-[#16A34A] text-white flex items-center justify-center gap-1.5 py-1.5 rounded-xl font-black text-[12px] shadow-sm active:scale-95 transition-all">
  268. <img src="/Millions/img/icons/icon_edit.png" onerror="this.style.display='none'" class="w-[16px] h-[16px] object-contain"> @Lang.millions_edit
  269. </button>
  270. <button onclick="clearTicket(this)" class="w-full bg-[#A855F7] text-white flex items-center justify-center gap-1.5 py-1.5 rounded-xl font-black text-[12px] shadow-sm active:scale-95 transition-all">
  271. <img src="/Millions/img/icons/icon_delete.png" onerror="this.style.display='none'" class="w-[16px] h-[16px] object-contain"> @Lang.millions_delete
  272. </button>
  273. </div>
  274. </div>
  275. </div>
  276. </div>
  277. </div>
  278. }
  279. @if (!isFreeTicketMode)
  280. {
  281. <div class="w-full pt-2" id="addButtonWrapper">
  282. <button onclick="addNewTicket()" class="w-fit min-w-[220px] mx-auto bg-[#2B83F2] text-white font-black text-md py-2.5 px-6 rounded-xl shadow-md border-b-[4px] border-[#1F66D6] active:translate-y-[1px] active:border-b-[1px] transition-all flex items-center justify-center gap-2">
  283. @Lang.millions_add_more_ticket
  284. </button>
  285. </div>
  286. }
  287. <div class="h-4"></div>
  288. </div>
  289. <!-- Bottom Action Bar -->
  290. <div class="ticket-bottom-bar p-4 bg-white border-t border-gray-200 z-[70] shadow-[0px_-4px_10px_rgba(0,0,0,0.03)]">
  291. <div class="flex items-center justify-between">
  292. <div class="flex flex-col">
  293. <div class="flex items-center gap-1.5 mb-0.5">
  294. <span class="text-[11px] text-black font-black uppercase">@Lang.total_ticket:</span>
  295. <span id="totalTicketCount" class="text-[12px] font-black text-black">0</span>
  296. </div>
  297. <span class="text-[11px] text-black font-black uppercase">@Lang.millions_estimated_ticket_price</span>
  298. <div class="flex items-baseline gap-1">
  299. <span id="totalPrice" class="text-[28px] font-black text-black">0</span>
  300. <span class="text-[13px] font-black text-[#0062FF]">HTG</span>
  301. </div>
  302. </div>
  303. <button type="button" onpointerdown="armPaymentClick(event)" onkeydown="armPaymentKey(event)" onclick="preparePayment(event)" class="bg-[#0062FF] text-white text-[20px] font-black px-10 py-3.5 rounded-xl shadow-[0px_6px_15px_rgba(238,0,51,0.25)] active:scale-95 transition-all">
  304. @Lang.millions_payment
  305. </button>
  306. </div>
  307. </div>
  308. </div>
  309. </div>
  310. }
  311. <!-- Payment channel selection -->
  312. <div id="paymentChannelModal" class="hidden fixed inset-0 z-[140] bg-black/70 backdrop-blur-[3px] items-center justify-center p-4 font-bricolage">
  313. <div class="relative w-full max-w-[370px] overflow-hidden rounded-[32px] bg-[#F8F9FC] shadow-[0_28px_70px_rgba(0,0,0,0.35)] animate__animated animate__zoomIn animate__faster">
  314. <div class="relative overflow-hidden bg-gradient-to-br from-[#0062FF] to-[#003FA8] px-6 pb-7 pt-6 text-white">
  315. <div class="absolute -right-8 -top-10 h-32 w-32 rounded-full bg-white/10"></div><div class="absolute -bottom-12 -left-8 h-28 w-28 rounded-full bg-black/10"></div>
  316. <button type="button" onclick="hidePaymentChannelModal()" class="absolute right-4 top-4 z-10 flex h-9 w-9 items-center justify-center rounded-full bg-white/15 text-white transition hover:bg-white/25 active:scale-90" aria-label="Close"><i class="fa-solid fa-xmark"></i></button>
  317. <div class="relative z-[1] flex items-center gap-4"><div class="flex h-14 w-14 shrink-0 items-center justify-center rounded-2xl bg-white text-[25px] text-[#0062FF] shadow-lg"><i class="fa-solid fa-wallet"></i></div><div><h2 class="text-[21px] font-black leading-tight">@Lang.payment_method_title</h2><p class="mt-1 text-[13px] font-semibold text-white/80">@Lang.payment_method_subtitle</p></div></div>
  318. </div>
  319. <div class="space-y-3 p-5">
  320. <button type="button" onclick="selectPaymentChannel('@Constants.BASIC_WALLET_TICKET')" class="group flex w-full items-center gap-4 rounded-[20px] border-2 border-transparent bg-white p-4 text-left shadow-[0_5px_18px_rgba(31,41,55,0.07)] transition hover:-translate-y-0.5 hover:border-[#0062FF] active:scale-[0.98]">
  321. <span class="flex h-12 w-12 shrink-0 items-center justify-center rounded-2xl bg-[#E7F0FF] text-[21px] text-[#0062FF]"><i class="fa-solid fa-mobile-screen-button"></i></span><span class="min-w-0 flex-1"><span class="block text-[16px] font-black text-[#171A24]">@Lang.payment_main_account</span><span class="mt-0.5 block text-[12px] font-semibold text-gray-500">@Lang.payment_main_account_desc</span></span><span class="flex h-8 w-8 items-center justify-center rounded-full bg-gray-100 text-gray-400 transition group-hover:bg-[#0062FF] group-hover:text-white"><i class="fa-solid fa-chevron-right text-[12px]"></i></span>
  322. </button>
  323. <button type="button" onclick="selectPaymentChannel('@Constants.NATCASH_WALLET_TICKET')" class="group flex w-full items-center gap-4 rounded-[20px] border-2 border-transparent bg-white p-4 text-left shadow-[0_5px_18px_rgba(31,41,55,0.07)] transition hover:-translate-y-0.5 hover:border-[#0A9800] active:scale-[0.98]">
  324. <span class="flex h-12 w-12 shrink-0 items-center justify-center rounded-2xl bg-[#E7F8E6] text-[21px] text-[#0A9800]"><i class="fa-solid fa-wallet"></i></span><span class="min-w-0 flex-1"><span class="flex items-center gap-2 text-[16px] font-black text-[#171A24]">@Lang.payment_wallet <span class="rounded-full bg-[#E7F8E6] px-2 py-0.5 text-[9px] font-black text-[#0A9800]">PIN</span></span><span class="mt-0.5 block text-[12px] font-semibold text-gray-500">@Lang.payment_wallet_desc</span></span><span class="flex h-8 w-8 items-center justify-center rounded-full bg-gray-100 text-gray-400 transition group-hover:bg-[#0A9800] group-hover:text-white"><i class="fa-solid fa-chevron-right text-[12px]"></i></span>
  325. </button>
  326. <p class="pt-1 text-center text-[11px] font-semibold text-gray-400"><i class="fa-solid fa-shield-halved mr-1 text-[#0A9800]"></i>@Lang.payment_security_message</p>
  327. </div>
  328. </div>
  329. </div>
  330. <!-- Order Summary Screen (from Figma) -->
  331. <div id="orderSummaryModal" class="hidden fixed inset-0 z-[150] bg-black/60 flex items-center justify-center p-0 font-bricolage backdrop-blur-[2px]">
  332. <div class="w-full h-full bg-white flex flex-col animate__animated animate__fadeInRight animate__faster shadow-2xl relative lg:max-w-[414px]">
  333. <!-- Header đồng bộ tuyệt đối -->
  334. <div class="buy-ticket-modal-header sticky top-0 z-[60]">
  335. <button onclick="hideOrderSummary()" class="back-btn" type="button">
  336. <i class="fa-solid fa-arrow-left"></i>
  337. </button>
  338. <div class="header-title">
  339. @if (Model.termType == Constants.PIC10_BASIC_CODE) { <text>Basic Pick 10</text> }
  340. else if (Model.termType == Constants.Millions_CODE) { <text>Millions</text> }
  341. else if (Model.termType == Constants.PIC10_BIGSMALL_CODE) { @Lang.millions_big_small }
  342. else { @Lang.millions_odd_even }
  343. </div>
  344. </div>
  345. <!-- Content Area: Split into scrollable list and static summary -->
  346. <div class="flex-1 flex flex-col min-h-0 bg-gray-50">
  347. <!-- Scrollable Ticket List -->
  348. <div class="flex-1 overflow-y-auto p-5 pb-2">
  349. <div class="flex justify-between items-center px-1 mb-3">
  350. <span class="text-[14px] font-bold text-gray-800">Selected Tickets</span>
  351. <span class="text-[14px] font-bold text-gray-800">@Lang.price</span>
  352. </div>
  353. <!-- Ticket List -->
  354. <div id="summaryTicketList" class="flex flex-col gap-4">
  355. <!-- Populated dynamically via JS -->
  356. </div>
  357. </div>
  358. <!-- Static Summary Info (Dates & Totals) -->
  359. <div class="shrink-0 bg-white p-5 space-y-4 border-t border-gray-100 shadow-[0px_-10px_20px_rgba(0,0,0,0.03)]">
  360. <!-- Dates Section -->
  361. <div class="grid grid-cols-2 gap-4">
  362. <div class="space-y-1">
  363. <span class="text-[11px] font-black text-[#0062FF] block text-center uppercase tracking-tight">@Lang.date_purchase</span>
  364. <div class="bg-white border border-gray-100 rounded-xl py-2.5 px-2 text-center font-black text-[11px] text-gray-700 shadow-sm">
  365. @DateTime.Now.ToString("dddd MMM dd, yyyy", new System.Globalization.CultureInfo("en-US"))
  366. </div>
  367. </div>
  368. <div class="space-y-1">
  369. <span class="text-[11px] font-black text-[#0062FF] block text-center uppercase tracking-tight">@Lang.draw_date</span>
  370. <div class="bg-white border border-gray-100 rounded-xl py-2.5 px-2 text-center font-black text-[11px] text-gray-700 shadow-sm" id="summaryResultDate">
  371. @{
  372. DateTime drawDate;
  373. bool isValidDate = DateTime.TryParse(currentTerm?.date_end, out drawDate);
  374. if (isValidDate) {
  375. @drawDate.ToString("dddd MMM dd, yyyy", new System.Globalization.CultureInfo("en-US"))
  376. } else {
  377. @:N/A
  378. }
  379. }
  380. </div>
  381. </div>
  382. </div>
  383. <!-- Totals Section -->
  384. <div class="space-y-1 px-1">
  385. <div class="flex justify-between items-center">
  386. <span class="text-[14px] font-bold text-black">@Lang.total_ticket</span>
  387. <span id="summaryTotalCount" class="text-[16px] font-black text-black">0</span>
  388. </div>
  389. <div class="flex justify-between items-center">
  390. <span class="text-[14px] font-bold text-black">@Lang.total_money</span>
  391. <div class="flex items-baseline gap-1">
  392. <span id="summaryTotalAmount" class="text-[32px] font-black text-black">0</span>
  393. <span class="text-[16px] font-black text-[#0062FF]">HTG</span>
  394. </div>
  395. </div>
  396. </div>
  397. </div>
  398. </div>
  399. <div class="shrink-0 p-4 bg-white border-t border-gray-100 grid grid-cols-2 gap-4 pb-8 shadow-[0px_-4px_20px_rgba(0,0,0,0.05)]">
  400. <button onclick="hideOrderSummary()" class="bg-[#FFB000] text-white py-2.5 rounded-2xl font-black text-[18px] shadow-lg shadow-orange-200 active:scale-95 transition-all uppercase tracking-wide">
  401. @Lang.reorder
  402. </button>
  403. <button id="finalPaymentBtn" onclick="confirmCheckout(this)" class="bg-[#0062FF] text-white py-2.5 rounded-2xl font-black text-[18px] shadow-lg shadow-red-200 active:scale-95 transition-all uppercase tracking-wide">
  404. @Lang.millions_payment
  405. </button>
  406. </div>
  407. </div>
  408. </div>
  409. <!-- Payment source selection -->
  410. <div id="paymentSourceModal" class="fixed inset-0 bg-black/70 backdrop-blur-sm z-[190] hidden items-center justify-center p-4 font-bricolage">
  411. <div class="bg-white w-full max-w-[350px] rounded-[28px] overflow-hidden shadow-2xl animate__animated animate__zoomIn animate__faster">
  412. <div class="bg-[#0062FF] px-5 py-4 text-white text-center relative">
  413. <h2 class="text-[19px] font-black">@Lang.millions_choose_account</h2>
  414. <button type="button" onclick="hidePaymentSourceModal()" class="absolute right-3 top-3 w-9 h-9 rounded-full bg-white/15 flex items-center justify-center">
  415. <i class="fa-solid fa-xmark"></i>
  416. </button>
  417. </div>
  418. <div class="p-5 grid gap-3">
  419. <button type="button" onclick="selectPaymentSource('@Constants.BASIC_WALLET_TICKET', this)" class="payment-source-button w-full border-2 border-[#0062FF] rounded-2xl px-4 py-4 flex items-center gap-4 text-left active:scale-[0.98] transition-all">
  420. <span class="w-11 h-11 rounded-full bg-[#0062FF]/10 text-[#0062FF] flex items-center justify-center"><i class="fa-solid fa-mobile-screen-button text-xl"></i></span>
  421. <span class="font-black text-[16px] text-gray-800">@Lang.basic_account</span>
  422. </button>
  423. <button type="button" onclick="selectPaymentSource('@Constants.NATCASH_WALLET_TICKET', this)" class="payment-source-button w-full border-2 border-[#0A9800] rounded-2xl px-4 py-4 flex items-center gap-4 text-left active:scale-[0.98] transition-all">
  424. <span class="w-11 h-11 rounded-full bg-[#0A9800]/10 text-[#0A9800] flex items-center justify-center"><i class="fa-solid fa-wallet text-xl"></i></span>
  425. <span class="font-black text-[16px] text-gray-800">@Lang.NatCash</span>
  426. </button>
  427. </div>
  428. </div>
  429. </div>
  430. <!-- OTP Verification Modal (V2 Design Overhaul - Matching Figma) -->
  431. <div id="otpModal" class="fixed inset-0 bg-black/80 backdrop-blur-sm z-[200] hidden items-center justify-center p-4">
  432. <!-- Outer container to hold the modal + external overflowing elements (like stars/glitter) -->
  433. <div class="relative w-full max-w-[360px] mt-6 animate__animated animate__zoomIn animate__faster">
  434. <!-- Glitter effect (external to the white box) -->
  435. <div class="absolute -top-[100px] -left-[10px] w-[380px] h-[160px] mix-blend-screen pointer-events-none z-0 overflow-visible opacity-90" style="background: url('/Millions/img/modal/otp_glitter.png') no-repeat center center; background-size: contain;"></div>
  436. <!-- The White Box -->
  437. <div class="bg-white rounded-[32px] w-full relative z-10 shadow-[0px_0px_30px_rgba(255,255,255,0.15)] pb-5 border border-yellow-500/20">
  438. <!-- Floating Coins from Figma -->
  439. <div class="absolute -top-[40px] -right-[10px] z-[80] w-[120px] pointer-events-none drop-shadow-2xl">
  440. <img src="/Millions/img/modal/otp_coins.png" class="w-full object-contain" />
  441. </div>
  442. <!-- Red Header Section -->
  443. <div class="relative w-full pt-4 pb-4 bg-[#0062FF] rounded-t-[32px] flex flex-col items-center justify-center z-20" style="border-bottom-left-radius: 50% 20px; border-bottom-right-radius: 50% 20px;">
  444. <h2 class="text-white text-[17px] sm:text-[20px] font-[900] uppercase tracking-wide relative z-10 font-bricolage drop-shadow-md text-center px-4 leading-tight w-[80%] mr-auto">@Lang.millions_confirm_purchase</h2>
  445. </div>
  446. <!-- Modal Body Content -->
  447. <div class="relative px-6 pt-3 flex flex-col items-center gap-3 z-10">
  448. <!-- Shield Icon: mix-blend-mode multiply to remove the white square background -->
  449. <div class="relative w-full flex justify-center mb-0 mt-1">
  450. <img src="/Millions/img/modal/otp_shield.png" alt="Success" class="w-[90px] object-contain">
  451. </div>
  452. <!-- Info Rows (Aligned exactly like screenshot) -->
  453. <div class="w-full flex flex-col gap-2 items-center mt-0">
  454. <!-- Ticket Info -->
  455. <div class="grid grid-cols-[90px_auto] items-center gap-3 w-full justify-center">
  456. <span class="text-[15px] font-bold text-[#555] text-right font-bricolage">@Lang.millions_ticket</span>
  457. <div id="otpTicketTypeContainer" class="flex justify-start">
  458. <img id="otpTicketTypeImg" src="/Millions/img/even_text.png" class="h-6 object-contain drop-shadow-sm" />
  459. </div>
  460. </div>
  461. <!-- Amount Info -->
  462. <div class="grid grid-cols-[90px_auto] items-center gap-3 w-full justify-center">
  463. <span class="text-[15px] font-bold text-[#555] text-right font-bricolage">@Lang.millions_amount</span>
  464. <div class="flex items-baseline gap-1.5 justify-start">
  465. <span id="otpTotalAmount" class="text-[22px] font-[900] text-black leading-none tracking-tight">1.000</span>
  466. <span class="text-[15px] font-[900] text-[#F37021] font-bricolage">HTG</span>
  467. </div>
  468. </div>
  469. </div>
  470. <p id="paymentCodeInstruction" class="text-[14px] font-bold text-[#555] text-center px-4 leading-snug mt-0 font-bricolage">@Lang.millions_otp_instruction</p>
  471. <!-- 6-Slots OTP Grid (Large Gray Blocks) -->
  472. <div class="flex items-center justify-center gap-2 w-full mt-1 px-2" id="otpInputs">
  473. @for (int i = 1; i <= 6; i++)
  474. {
  475. <input type="tel" maxlength="1" id="otp@(i)"
  476. oninput="moveToNext(this, '@(i < 6 ? "otp" + (i + 1) : "")')"
  477. class="w-[42px] h-[48px] bg-[#757575] rounded-[10px] text-white text-[26px] font-bold text-center appearance-none focus:bg-[#555] focus:scale-[1.03] focus:ring-2 focus:ring-[#0062FF]/50 transition-all outline-none shadow-inner otp-slot"
  478. placeholder="-">
  479. }
  480. </div>
  481. <div id="walletPinContainer" class="hidden w-full mt-1 px-2">
  482. <div class="relative">
  483. <i class="fa-solid fa-lock absolute left-4 top-1/2 -translate-y-1/2 text-[#0A9800]"></i>
  484. <input id="walletPinInput" type="password" inputmode="numeric" autocomplete="off"
  485. oninput="this.value = this.value.replace(/[^0-9]/g, ''); updateWalletPinState()"
  486. class="h-[52px] w-full rounded-[14px] border-2 border-gray-200 bg-gray-50 pl-11 pr-12 text-center text-[22px] font-black tracking-[0.3em] text-gray-800 outline-none transition focus:border-[#0A9800] focus:bg-white focus:ring-4 focus:ring-green-100"
  487. placeholder="••••">
  488. <button type="button" onclick="toggleWalletPinVisibility()" class="absolute right-4 top-1/2 -translate-y-1/2 text-gray-400 active:scale-90" aria-label="Show PIN"><i id="walletPinEye" class="fa-solid fa-eye"></i></button>
  489. </div>
  490. </div>
  491. <!-- OTP Error Message -->
  492. <p id="otpError" class="text-[#0062FF] font-bold text-[14px] text-center mb-1 hidden animate__animated animate__shakeX"></p>
  493. <!-- Timer & Resend -->
  494. <div class="flex flex-col items-center gap-1 mt-0">
  495. <span id="otpTimer" class="text-[15px] font-black text-[#0062FF] font-bricolage">60s</span>
  496. <button id="resendOtpBtn" onclick="sendOtpRequest()" class="hidden text-[14px] font-black text-[#0A9800] underline decoration-solid underline-offset-[3px] transition-all hover:text-[#087a00] disabled:opacity-40 disabled:no-underline font-bricolage">@Lang.millions_request_new_otp</button>
  497. </div>
  498. <!-- Action Buttons: Cancel / Confirm -->
  499. <div class="grid grid-cols-2 gap-3 w-full mt-2">
  500. <button onclick="hideOtpModal()" class="bg-[#FF0000] text-white py-[12px] rounded-[16px] font-[900] text-[17px] shadow-[0_8px_15px_rgba(255,0,0,0.2)] active:scale-95 transition-all tracking-wide">@Lang.millions_cancel</button>
  501. <button id="otpConfirmBtn" disabled onclick="finalizePurchase(this)" class="bg-[#0A9800] text-white py-[12px] rounded-[16px] font-[900] text-[17px] shadow-[0_8px_15px_rgba(10,152,0,0.2)] active:scale-95 transition-all tracking-wide disabled:opacity-50 disabled:grayscale disabled:cursor-not-allowed">@Lang.millions_confirm</button>
  502. </div>
  503. </div>
  504. </div>
  505. </div>
  506. </div>
  507. @section Scripts {
  508. <script>
  509. const maxBalls = @(Model.termType == Constants.PIC10_BASIC_CODE ? 10 : (Model.termType == Constants.Millions_CODE ? 6 : (Model.termType == Constants.PIC10_BIGSMALL_CODE ? 13 : 15)));
  510. const isFreeTicketMode = @(isFreeTicketMode ? "true" : "false");
  511. const hasFreeTicketPromotion = @(hasFreeTicketPromotion ? "true" : "false");
  512. const freeTicketPromotionCode = @Html.Raw(System.Text.Json.JsonSerializer.Serialize(freeTicketPromotionCode));
  513. function reindexTickets() {
  514. $(".ticket-card").each(function(index) {
  515. $(this).find(".ticket-index").text(index + 1);
  516. });
  517. }
  518. function removeEntry(btn) {
  519. var card = $(btn).closest('.ticket-card');
  520. card.addClass('animate__animated animate__fadeOutRight animate__faster');
  521. setTimeout(function() {
  522. card.remove();
  523. reindexTickets();
  524. updateTotalPrice();
  525. }, 300);
  526. }
  527. function randomizeTicket(btn) {
  528. var icon = $(btn).find('i');
  529. icon.addClass('fa-spin');
  530. var card = $(btn).closest('.ticket-card');
  531. var balls = card.find('.ball-circle');
  532. // Generate unique random numbers
  533. var numbers = [];
  534. if ("@Model.termType" === "@Constants.Millions_CODE") {
  535. // First 5 standard balls (1-70)
  536. while(numbers.length < 5){
  537. var r = Math.floor(Math.random() * 70) + 1;
  538. if(numbers.indexOf(r) === -1) numbers.push(r);
  539. }
  540. numbers.sort((a, b) => a - b);
  541. // 6th Mega Ball (1-24)
  542. var mb = Math.floor(Math.random() * 24) + 1;
  543. numbers.push(mb);
  544. } else {
  545. while(numbers.length < maxBalls){
  546. var r = Math.floor(Math.random() * 80) + 1;
  547. if(numbers.indexOf(r) === -1) numbers.push(r);
  548. }
  549. numbers.sort((a, b) => a - b);
  550. }
  551. // Update balls with staggered animation
  552. balls.each(function(index) {
  553. var ball = $(this);
  554. setTimeout(function() {
  555. var formattedNum = numbers[index].toString().padStart(2, '0');
  556. ball.removeClass('ball-empty').addClass('ball-filled').text(formattedNum);
  557. ball.addClass('animate__animated animate__flipInY');
  558. if(index === maxBalls - 1) {
  559. setTimeout(() => {
  560. icon.removeClass('fa-spin');
  561. // Replace button with Edit/Delete group
  562. $(btn).hide();
  563. card.find('.edit-delete-group').removeClass('hidden').addClass('animate__animated animate__fadeInRight animate__faster');
  564. updateTotalPrice();
  565. }, 300);
  566. }
  567. }, index * 40);
  568. });
  569. }
  570. function clearTicket(btn) {
  571. var card = $(btn).closest('.ticket-card');
  572. var balls = card.find('.ball-circle');
  573. balls.removeClass('ball-filled animate__animated animate__flipInY shadow-inner').addClass('ball-empty').text('');
  574. // Hide Edit/Delete group and show Rand button
  575. card.find('.edit-delete-group').addClass('hidden');
  576. card.find('.rand-btn').show().addClass('animate__animated animate__fadeInLeft animate__faster');
  577. updateTotalPrice();
  578. }
  579. // Open Number Picker Modal
  580. var activeBall = null;
  581. var activeTicketCard = null;
  582. var selectedNumbers = []; // For Edit mode, this will be an array of fixed size with nulls
  583. var isMultiMode = false;
  584. function editFullTicket(btn) {
  585. isMultiMode = true;
  586. activeTicketCard = $(btn).closest('.ticket-card');
  587. activeBall = null;
  588. // Initialize fixed slots for slot-based editing
  589. selectedNumbers = new Array(maxBalls).fill(null);
  590. let existing = [];
  591. activeTicketCard.find('.ball-filled').each(function() {
  592. var num = $(this).text().trim();
  593. if(num) existing.push(num);
  594. });
  595. // Initial fill from left to right
  596. existing.forEach((num, idx) => {
  597. if(idx < maxBalls) selectedNumbers[idx] = num;
  598. });
  599. openNumberPicker(true);
  600. }
  601. function openNumberPicker(isMulti) {
  602. var modal = $("#numberPickerModal");
  603. var grid = $("#numberGrid");
  604. var title = $("#modalTitle");
  605. var countArea = $(".selection-count-area");
  606. var confirmBtn = $("#confirmBtn");
  607. grid.empty();
  608. if (isMulti) {
  609. title.text("Edit Ticket");
  610. countArea.removeClass('hidden');
  611. confirmBtn.removeClass('hidden').text("@Lang.confirm");
  612. } else {
  613. title.text("Pick Number");
  614. countArea.addClass('hidden');
  615. confirmBtn.removeClass('hidden').text("@Lang.confirm");
  616. }
  617. updateSelectionCount();
  618. liveUpdateTicket();
  619. // Focus card: append a tall spacer so even the last ticket can scroll up
  620. // above the number-picker sheet (a flex column container does not honor
  621. // padding-bottom as scrollable space), then bring the card to the top.
  622. if (activeTicketCard && activeTicketCard.length) {
  623. var container = $("#ticketContainer");
  624. $("#editScrollSpacer").remove();
  625. container.append('<div id="editScrollSpacer" aria-hidden="true" style="height:100vh;flex-shrink:0;"></div>');
  626. var scrollPos = activeTicketCard.offset().top - container.offset().top + container.scrollTop();
  627. container.stop().animate({ scrollTop: scrollPos - 15 }, 500);
  628. }
  629. var isMillions = "@Model.termType" === "@Constants.Millions_CODE";
  630. if (isMillions) {
  631. // Millions Split UI: 1-70 (cols-7) | Divider | 1-24 (cols-3)
  632. var splitHtml = `
  633. <div class="flex gap-3 h-full">
  634. <!-- Left: Standard (1-70) -->
  635. <div class="flex-1 flex flex-col h-full min-w-0">
  636. <span class="text-[10px] font-black text-blue-600 mb-1 uppercase tracking-wider shrink-0">Standard (1-70)</span>
  637. <div class="flex-1 overflow-y-auto grid grid-cols-7 gap-1 pr-1 pb-2" id="standardGrid" style="scrollbar-width: thin; scrollbar-color: #0062FF transparent;"></div>
  638. </div>
  639. <!-- Divider -->
  640. <div class="w-[1px] bg-gray-300 self-stretch my-1 shrink-0"></div>
  641. <!-- Right: Mega Ball (1-24) -->
  642. <div class="w-[105px] flex flex-col h-full shrink-0">
  643. <span class="text-[10px] font-black text-red-600 mb-1 uppercase tracking-wider shrink-0 text-center">Mega (1-24)</span>
  644. <div class="flex-1 overflow-y-auto grid grid-cols-3 gap-1 pl-1 pb-2" id="megaGrid" style="scrollbar-width: thin; scrollbar-color: #E3132D transparent;"></div>
  645. </div>
  646. </div>
  647. `;
  648. grid.append(splitHtml);
  649. var standardContainer = $("#standardGrid");
  650. var megaContainer = $("#megaGrid");
  651. // Populate Standard (1-70)
  652. for (var i = 1; i <= 70; i++) {
  653. var formatted = i.toString().padStart(2, '0');
  654. var isSelected = selectedNumbers.slice(0, 5).includes(formatted);
  655. var btnClass = isSelected
  656. ? 'bg-[#0062FF] text-white shadow-sm'
  657. : 'bg-white text-gray-700 hover:bg-gray-100 border border-gray-100';
  658. standardContainer.append(`<button type="button" class="std-num-btn w-[26px] h-[26px] rounded-full font-black text-[9.5px] transition-all flex items-center justify-center ${btnClass}">${formatted}</button>`);
  659. }
  660. // Populate Mega (1-24)
  661. for (var i = 1; i <= 24; i++) {
  662. var formatted = i.toString().padStart(2, '0');
  663. var isSelected = selectedNumbers[5] === formatted;
  664. var btnClass = isSelected
  665. ? 'bg-[#E3132D] text-white shadow-sm'
  666. : 'bg-white text-gray-700 hover:bg-gray-100 border border-gray-100';
  667. megaContainer.append(`<button type="button" class="mega-num-btn w-[26px] h-[26px] rounded-full font-black text-[9.5px] transition-all flex items-center justify-center ${btnClass}">${formatted}</button>`);
  668. }
  669. // Standard Grid Click Handler
  670. standardContainer.on('click', '.std-num-btn', function(e) {
  671. e.preventDefault();
  672. var $btn = $(this);
  673. var picked = $btn.text().trim();
  674. if (isMultiMode) {
  675. var stdSelected = selectedNumbers.slice(0, 5);
  676. if (stdSelected.includes(picked)) {
  677. // Deselect
  678. let idx = selectedNumbers.indexOf(picked);
  679. if (idx !== -1 && idx < 5) selectedNumbers[idx] = null;
  680. $btn.removeClass('bg-[#0062FF] text-white shadow-sm').addClass('bg-white text-gray-700 border border-gray-100');
  681. } else {
  682. // Select standard ball (first empty slot in 0-4)
  683. let emptyIdx = -1;
  684. for (var k = 0; k < 5; k++) {
  685. if (selectedNumbers[k] === null) {
  686. emptyIdx = k;
  687. break;
  688. }
  689. }
  690. if (emptyIdx !== -1) {
  691. selectedNumbers[emptyIdx] = picked;
  692. $btn.addClass('bg-[#0062FF] text-white shadow-sm').removeClass('bg-white text-gray-700 border border-gray-100');
  693. }
  694. }
  695. liveUpdateTicket();
  696. }
  697. updateSelectionCount();
  698. });
  699. // Mega Grid Click Handler
  700. megaContainer.on('click', '.mega-num-btn', function(e) {
  701. e.preventDefault();
  702. var $btn = $(this);
  703. var picked = $btn.text().trim();
  704. if (isMultiMode) {
  705. if (selectedNumbers[5] === picked) {
  706. // Deselect Mega Ball
  707. selectedNumbers[5] = null;
  708. $btn.removeClass('bg-[#E3132D] text-white shadow-sm').addClass('bg-white text-gray-700 border border-gray-100');
  709. } else {
  710. // Overwrite Mega Ball
  711. selectedNumbers[5] = picked;
  712. megaContainer.find('.mega-num-btn').removeClass('bg-[#E3132D] text-white shadow-sm').addClass('bg-white text-gray-700 border border-gray-100');
  713. $btn.addClass('bg-[#E3132D] text-white shadow-sm').removeClass('bg-white text-gray-700 border border-gray-100');
  714. }
  715. liveUpdateTicket();
  716. }
  717. updateSelectionCount();
  718. });
  719. } else {
  720. // Default Pick 10 UI: 1-80 Grid
  721. var normalHtml = `<div class="grid grid-cols-10 gap-1.5 w-full pb-2 h-full overflow-y-auto" id="normalGrid"></div>`;
  722. grid.append(normalHtml);
  723. var normalContainer = $("#normalGrid");
  724. for (var i = 1; i <= 80; i++) {
  725. var formatted = i.toString().padStart(2, '0');
  726. var isSelected = selectedNumbers.includes(formatted);
  727. var btnClass = isSelected
  728. ? 'bg-[#0062FF] text-white shadow-md scale-105 active-num'
  729. : 'bg-white text-gray-700 hover:bg-gray-100 border border-gray-100';
  730. normalContainer.append(`<button type="button" class="num-btn w-8 h-8 rounded-full font-black text-[11px] transition-all focus:outline-none flex items-center justify-center ${btnClass}">${formatted}</button>`);
  731. }
  732. normalContainer.on('click', '.num-btn', function(e) {
  733. e.preventDefault();
  734. var $btn = $(this);
  735. var picked = $btn.text().trim();
  736. if (isMultiMode) {
  737. if (selectedNumbers.includes(picked)) {
  738. let idx = selectedNumbers.indexOf(picked);
  739. if (idx !== -1) selectedNumbers[idx] = null;
  740. $btn.removeClass('bg-[#0062FF] text-white shadow-md scale-105 active-num').addClass('bg-white text-gray-700 border border-gray-100');
  741. } else {
  742. let firstEmpty = selectedNumbers.indexOf(null);
  743. if (firstEmpty !== -1) {
  744. selectedNumbers[firstEmpty] = picked;
  745. $btn.addClass('bg-[#0062FF] text-white shadow-md scale-105 active-num').removeClass('bg-white text-gray-700 border border-gray-100');
  746. }
  747. }
  748. liveUpdateTicket();
  749. }
  750. updateSelectionCount();
  751. });
  752. }
  753. modal.removeClass('hidden').addClass('flex');
  754. modal.find('.modal-content').removeClass('animate__zoomOut').addClass('animate__zoomIn');
  755. }
  756. function updateSelectionCount() {
  757. var count = selectedNumbers.filter(n => n !== null && n !== "").length;
  758. $("#selectionCount").text(count);
  759. $("#maxSelectionCount").text(maxBalls);
  760. var isValid = isMultiMode ? (count === maxBalls) : (count === 1);
  761. if (isValid) {
  762. $("#confirmBtn").prop('disabled', false).removeClass('opacity-50 cursor-not-allowed').addClass('cursor-pointer');
  763. } else {
  764. $("#confirmBtn").prop('disabled', true).addClass('opacity-50 cursor-not-allowed').removeClass('cursor-pointer');
  765. }
  766. }
  767. function liveUpdateTicket() {
  768. if (!activeTicketCard) return;
  769. var balls = activeTicketCard.find('.ball-circle');
  770. if (isMultiMode) {
  771. // Update Ticket Card balls
  772. for(var i=0; i < maxBalls; i++){
  773. var val = selectedNumbers[i];
  774. if (i < balls.length) {
  775. var tBall = $(balls[i]);
  776. if (val) {
  777. tBall.removeClass('ball-empty').addClass('ball-filled').text(val);
  778. } else {
  779. tBall.removeClass('ball-filled').addClass('ball-empty').text('');
  780. }
  781. }
  782. }
  783. // Toggle Rand/Edit button visibility
  784. if (selectedNumbers.filter(n => n !== null && n !== "").length > 0) {
  785. activeTicketCard.find('.rand-btn').hide();
  786. activeTicketCard.find('.edit-delete-group').removeClass('hidden').show();
  787. } else {
  788. activeTicketCard.find('.rand-btn').show();
  789. activeTicketCard.find('.edit-delete-group').addClass('hidden');
  790. }
  791. updateTotalPrice();
  792. }
  793. }
  794. // All immediate jQuery event bindings must wait for DOM + jQuery to be ready
  795. document.addEventListener("DOMContentLoaded", function() {
  796. // Click on a ball (filled or empty) to edit the full ticket
  797. $(document).on('click', '.ball-filled, .ball-empty', function() {
  798. editFullTicket(this);
  799. });
  800. updateTotalPrice();
  801. // Confirm button handler
  802. $(document).off('click', '#confirmBtn').on('click', '#confirmBtn', function(e) {
  803. e.preventDefault();
  804. // Check non-null count
  805. var count = selectedNumbers.filter(n => n !== null && n !== "").length;
  806. if (count === 0) return;
  807. if (isMultiMode && activeTicketCard && activeTicketCard.length > 0) {
  808. // Double check validation for Mega Ball before confirming
  809. if ("@Model.termType" === "@Constants.Millions_CODE") {
  810. var mbVal = selectedNumbers[5];
  811. if (mbVal) {
  812. var mbValInt = parseInt(mbVal);
  813. if (mbValInt < 1 || mbValInt > 24) {
  814. showNotification("🎱 @Lang.millions_megaball_invalid_title\n@Lang.millions_megaball_invalid_desc", "warning");
  815. return;
  816. }
  817. }
  818. }
  819. // Keep exact selected order, do not sort!
  820. var finalSorted = [];
  821. if ("@Model.termType" === "@Constants.Millions_CODE") {
  822. var first5 = selectedNumbers.slice(0, 5).filter(n => n !== null && n !== "");
  823. var mb = selectedNumbers[5];
  824. finalSorted = first5;
  825. if (mb) finalSorted.push(mb);
  826. } else {
  827. finalSorted = selectedNumbers.filter(n => n !== null && n !== "");
  828. }
  829. var balls = activeTicketCard.find('.ball-circle');
  830. balls.removeClass('ball-filled').addClass('ball-empty').text('');
  831. finalSorted.forEach((num, index) => {
  832. if (index < balls.length) {
  833. $(balls[index]).removeClass('ball-empty').addClass('ball-filled').text(num);
  834. $(balls[index]).addClass('animate__animated animate__pulse');
  835. setTimeout(() => $(balls[index]).removeClass('animate__animated animate__pulse'), 500);
  836. }
  837. });
  838. activeTicketCard.find('.rand-btn').hide();
  839. activeTicketCard.find('.edit-delete-group').removeClass('hidden').show();
  840. updateTotalPrice();
  841. } else if (!isMultiMode && activeBall && activeBall.length > 0) {
  842. // Single mode: Update only the active ball
  843. activeBall.text(selectedNumbers[0]).removeClass('ball-empty').addClass('ball-filled');
  844. activeBall.addClass('animate__animated animate__pulse');
  845. setTimeout(() => activeBall.removeClass('animate__animated animate__pulse'), 500);
  846. var card = activeBall.closest('.ticket-card');
  847. var filledBalls = card.find('.ball-filled').length;
  848. if (filledBalls > 0) {
  849. card.find('.rand-btn').hide();
  850. card.find('.edit-delete-group').removeClass('hidden').show();
  851. } else {
  852. card.find('.rand-btn').show();
  853. card.find('.edit-delete-group').addClass('hidden');
  854. }
  855. updateTotalPrice();
  856. }
  857. closeNumberPicker();
  858. });
  859. });
  860. function closeNumberPicker() {
  861. var modal = $("#numberPickerModal");
  862. modal.find('.modal-content').removeClass('animate__zoomIn').addClass('animate__zoomOut');
  863. setTimeout(() => {
  864. modal.removeClass('flex').addClass('hidden');
  865. // Remove the temporary scroll spacer
  866. $("#editScrollSpacer").remove();
  867. // Reset state
  868. activeBall = null;
  869. activeTicketCard = null;
  870. }, 200);
  871. }
  872. function updateTotalPrice() {
  873. var filledTickets = 0;
  874. $(".ticket-card").each(function() {
  875. if ($(this).find(".ball-filled").length === maxBalls) {
  876. filledTickets++;
  877. }
  878. });
  879. const pricePerTicket = hasFreeTicketPromotion
  880. ? 0
  881. : @(Model.termType == Constants.PIC10_BASIC_CODE ? "10" : (Model.termType == Constants.Millions_CODE ? "20" : "50"));
  882. $("#totalPrice").text(formatMoneyV2(filledTickets * pricePerTicket));
  883. $("#totalTicketCount").text(filledTickets);
  884. }
  885. function addNewTicket() {
  886. if (isFreeTicketMode) return;
  887. var container = $("#ticketContainer");
  888. var wrapper = $("#addButtonWrapper");
  889. var currentIndex = $(".ticket-card").length + 1;
  890. var ballsHtml = '';
  891. var isMillions = @(Model.termType == Constants.Millions_CODE ? "true" : "false");
  892. for (var i = 0; i < maxBalls; i++) {
  893. var isMbBall = isMillions && i === 5;
  894. var mbIndicator = isMbBall ? '<div class="absolute -bottom-[6px] -right-[4px] bg-[#FFD700] text-black text-[8.5px] font-black px-[2.5px] py-[1.5px] rounded-[3px] shadow-sm leading-none z-10 border border-[#EAA800]">MB</div>' : '';
  895. ballsHtml += '<div class="relative w-fit"><div class="ball-circle ball-empty' + (isMbBall ? ' ball-mb-circle' : '') + '"></div>' + mbIndicator + '</div>';
  896. }
  897. var ticketHtml = `
  898. <div class="ticket-card relative group active:bg-gray-50 transition-colors cursor-pointer animate__animated animate__fadeInUp animate__faster">
  899. <button onclick="removeEntry(this)" class="absolute -right-2 top-1 w-7 h-7 bg-[#FF0000] text-white rounded-full flex items-center justify-center text-[11px] shadow-sm z-[10] hover:bg-red-700 transition-all border-2 border-red-600">
  900. <i class="fa-solid fa-xmark"></i>
  901. </button>
  902. <div class="absolute left-2 top-4 w-9 h-9 rounded-full border-[3px] border-white flex items-center justify-center text-white font-black text-sm shadow-md ticket-index">${currentIndex}</div>
  903. <div class="flex flex-col gap-1 pl-8">
  904. <span class="text-[16px] font-extrabold text-[#333]">@Lang.millions_select_10_lucky_numbers</span>
  905. <div class="flex items-center gap-4">
  906. <div class="grid grid-cols-6 gap-y-2 gap-x-1 flex-1">
  907. ${ballsHtml}
  908. </div>
  909. <div class="w-[90px] action-area flex flex-col gap-2">
  910. <button onclick="randomizeTicket(this)" class="rand-btn w-full bg-[#2B83F2] text-white flex items-center justify-center gap-1.5 py-1.5 rounded-xl font-extrabold text-[11px] shadow-sm active:scale-95 transition-all">
  911. <i class="fa-solid fa-arrows-rotate text-[10px]"></i> @Lang.Random
  912. </button>
  913. <div class="edit-delete-group hidden flex flex-col gap-2">
  914. <button onclick="editFullTicket(this)" class="w-full bg-[#16A34A] text-white flex items-center justify-center gap-1.5 py-1.5 rounded-xl font-black text-[12px] shadow-sm active:scale-95 transition-all">
  915. <img src="/Millions/img/icons/icon_edit.png" onerror="this.style.display='none'" class="w-[16px] h-[16px] object-contain"> @Lang.millions_edit
  916. </button>
  917. <button onclick="clearTicket(this)" class="w-full bg-[#A855F7] text-white flex items-center justify-center gap-1.5 py-1.5 rounded-xl font-black text-[12px] shadow-sm active:scale-95 transition-all">
  918. <img src="/Millions/img/icons/icon_delete.png" onerror="this.style.display='none'" class="w-[16px] h-[16px] object-contain"> @Lang.millions_delete
  919. </button>
  920. </div>
  921. </div>
  922. </div>
  923. </div>
  924. </div>
  925. `;
  926. $(ticketHtml).insertBefore(wrapper);
  927. container.animate({ scrollTop: container.prop("scrollHeight") }, 300);
  928. }
  929. // --- Order Summary Modal Logic ---
  930. // --- Payment Preparation & Order Summary Logic ---
  931. let pendingPaymentRequest = null;
  932. let pendingTickets = [];
  933. let currentChannelPayment = '@Constants.BASIC_WALLET_TICKET';
  934. let isPreparingCheckout = false;
  935. let isSendingOtp = false;
  936. let isFinalizingPurchase = false;
  937. let paymentClickArmedAt = 0;
  938. function armPaymentClick(event) {
  939. if (event && event.isTrusted === true) paymentClickArmedAt = Date.now();
  940. }
  941. function armPaymentKey(event) {
  942. if (event && event.isTrusted === true && (event.key === "Enter" || event.key === " ")) {
  943. paymentClickArmedAt = Date.now();
  944. }
  945. }
  946. function preparePayment(event) {
  947. // Never prepare or confirm a ticket during page initialization.
  948. // A trusted pointer/key action on this button must immediately precede the click.
  949. const hasFreshPaymentIntent = paymentClickArmedAt > 0
  950. && Date.now() - paymentClickArmedAt <= 1500;
  951. paymentClickArmedAt = 0;
  952. if (!event || event.type !== "click" || event.isTrusted !== true || !hasFreshPaymentIntent) return;
  953. const isBSMode = @(Model.termType == Constants.PIC10_BIGSMALL_CODE || Model.termType == Constants.PIC10_ODDEVEN_CODE ? "true" : "false");
  954. const tickets = [];
  955. if (isBSMode) {
  956. if (!bsChoice) {
  957. showNotification("Please select a choice first.", "warning");
  958. return;
  959. }
  960. let bsCode = "";
  961. if ('@Model.termType' === '@Constants.PIC10_BIGSMALL_CODE') {
  962. bsCode = (bsChoice === 'big') ? "B" : "S";
  963. } else {
  964. bsCode = (bsChoice === 'big') ? "O" : "E"; // Odd = O, Even = E
  965. }
  966. tickets.push({
  967. code: bsCode,
  968. money: "50"
  969. });
  970. } else {
  971. $(".ticket-card").each(function() {
  972. if (isFreeTicketMode && tickets.length >= 1) return false;
  973. const balls = $(this).find(".ball-filled");
  974. if (balls.length === maxBalls) {
  975. const selectedNumbers = [];
  976. balls.each(function() { selectedNumbers.push($(this).text().trim()); });
  977. const itemPrice = "@(Model.termType == Constants.PIC10_BASIC_CODE ? "10" : (Model.termType == Constants.Millions_CODE ? "20" : "50"))";
  978. tickets.push({
  979. code: selectedNumbers.join(','),
  980. money: itemPrice
  981. });
  982. }
  983. });
  984. if (tickets.length === 0) {
  985. showNotification("@Lang.millions_ticket_not_valid", "warning");
  986. return;
  987. }
  988. }
  989. pendingPaymentRequest = {
  990. gameId: "@Model.termType",
  991. ticket: tickets
  992. };
  993. showOrderSummary(null, tickets);
  994. pendingTickets = tickets;
  995. if (hasFreeTicketPromotion) {
  996. selectPaymentChannel('@Constants.BASIC_WALLET_TICKET');
  997. return;
  998. }
  999. $("#paymentChannelModal").removeClass("hidden").addClass("flex");
  1000. }
  1001. function hidePaymentChannelModal() {
  1002. $("#paymentChannelModal").removeClass("flex").addClass("hidden");
  1003. }
  1004. function selectPaymentChannel(channelPayment) {
  1005. if (isPreparingCheckout) return;
  1006. isPreparingCheckout = true;
  1007. currentChannelPayment = channelPayment;
  1008. hidePaymentChannelModal();
  1009. const requestData = {
  1010. gameId: isFreeTicketMode ? "@Constants.Millions_CODE" : "@Model.termType",
  1011. ticket: pendingTickets,
  1012. channelPayment: channelPayment,
  1013. promotionCode: isFreeTicketMode ? freeTicketPromotionCode : null
  1014. };
  1015. $.ajax({
  1016. url: subDomain + '@Url.Action("ConfirmTicketData", "Home")',
  1017. type: 'POST',
  1018. contentType: 'application/json',
  1019. data: JSON.stringify(requestData),
  1020. success: function(data) {
  1021. if (data.responseCode === "0" || data.responseCode === "0000") {
  1022. showOrderSummary(data, pendingTickets);
  1023. } else {
  1024. showNotification(data.responseMessage || "Confirmation failed", data.responseCode);
  1025. }
  1026. },
  1027. error: function(err) {
  1028. showNotification("Network error occurred.", "warning");
  1029. },
  1030. complete: function() {
  1031. isPreparingCheckout = false;
  1032. }
  1033. });
  1034. }
  1035. let currentTransId = null;
  1036. function showOrderSummary(apiData, localTickets) {
  1037. currentTransId = apiData ? apiData.transId : null;
  1038. const summaryModal = $("#orderSummaryModal");
  1039. const summaryList = $("#summaryTicketList");
  1040. summaryList.empty();
  1041. const displayTickets = (apiData && apiData.ticket) ? apiData.ticket : (localTickets || []);
  1042. if (!displayTickets || !Array.isArray(displayTickets)) {
  1043. console.warn("No tickets found to display in summary.");
  1044. return;
  1045. }
  1046. displayTickets.forEach((t, index) => {
  1047. const numbers = t.code.split(',');
  1048. let contentHtml = '';
  1049. if (numbers.length > 1) {
  1050. const isMillionsGame = "@Model.termType" === "@Constants.Millions_CODE";
  1051. let numbersBalls = '';
  1052. numbers.forEach((n, ni) => {
  1053. var isMbBall = isMillionsGame && ni === numbers.length - 1;
  1054. var ballBg = isMbBall
  1055. ? 'background: radial-gradient(circle at 50% 50%, #0062ff 0%, #0062ff 60%, #0149f0 75%, #0231e0 85%, #0218d1 92%, #0300c2 100%); box-shadow: inset 0 0 6px 2px rgba(0,24,209,0.5), 0 4px 10px rgba(2,24,209,0.3);'
  1056. : 'background: linear-gradient(135deg, #FF3D63 0%, #E3132D 60%, #BA0F21 100%); box-shadow: 0 4px 10px rgba(186,15,33,0.3);';
  1057. numbersBalls += `<div class="w-7 h-7 rounded-full flex items-center justify-center text-white text-[11px] font-black" style="${ballBg} border: 1px solid rgba(255, 255, 255, 0.3); text-shadow: 0px 1px 2px rgba(0,0,0,0.1); transition: transform 0.2s;">${n.trim()}</div>`;
  1058. });
  1059. var summaryGridCols = isMillionsGame ? 'grid-cols-6' : 'grid-cols-5';
  1060. contentHtml = `<div class="grid ${summaryGridCols} gap-y-2 gap-x-1 relative z-10 px-1 justify-items-center">${numbersBalls}</div>`;
  1061. } else {
  1062. const isBS = @(Model.termType == Constants.PIC10_BIGSMALL_CODE ? "true" : "false");
  1063. const isFirstChoice = (numbers[0] === 'B' || numbers[0] === 'O');
  1064. const label = isFirstChoice ? (isBS ? "Big" : "Odd") : (isBS ? "Small" : "Even");
  1065. const color = isFirstChoice ? (isBS ? "#A2FF00" : "#FFC700") : (isBS ? "#FF4157" : "#B33BD0");
  1066. contentHtml = `<div class="w-full flex justify-center"><span class="text-[28px] font-black italic uppercase" style="-webkit-text-stroke: 1px #000; color: ${color};">${label}</span></div>`;
  1067. }
  1068. const itemHtml = `
  1069. <div class="flex items-center gap-3">
  1070. <div class="flex-1 rounded-2xl p-3 relative overflow-hidden flex flex-col gap-2 min-h-[80px] justify-center shadow-sm"
  1071. style="background: white; border: 1.5px solid #0062FF;">
  1072. ${contentHtml}
  1073. </div>
  1074. <div class="w-24 shrink-0 bg-white border border-gray-200 rounded-2xl p-2.5 flex items-center justify-center shadow-sm">
  1075. <div class="flex items-baseline gap-0.5">
  1076. <span class="text-[20px] font-black text-black">${formatMoneyV2(hasFreeTicketPromotion ? 0 : t.money)}</span>
  1077. <span class="text-[12px] font-black text-[#0062FF]">HTG</span>
  1078. </div>
  1079. </div>
  1080. </div>
  1081. `;
  1082. summaryList.append(itemHtml);
  1083. });
  1084. $("#summaryTotalCount").text(displayTickets.length);
  1085. const totalMoney = apiData
  1086. ? (apiData.totalMoneyPayment || apiData.totalMoney || "0")
  1087. : displayTickets.reduce((sum, ticket) => sum + (parseInt(ticket.money, 10) || 0), 0);
  1088. const totalMoney = hasFreeTicketPromotion
  1089. ? "0"
  1090. : (apiData.totalMoneyPayment || apiData.totalMoney || "0");
  1091. $("#summaryTotalAmount").text(formatMoneyV2(totalMoney));
  1092. summaryModal.removeClass("hidden").addClass("flex");
  1093. }
  1094. function hideOrderSummary() {
  1095. $("#orderSummaryModal").removeClass("flex").addClass("hidden");
  1096. }
  1097. function confirmCheckout(btn) {
  1098. if (!pendingPaymentRequest) {
  1099. showNotification("@Lang.millions_ticket_not_valid", "warning");
  1100. return;
  1101. }
  1102. if (isSendingOtp) return;
  1103. if (currentChannelPayment === '@Constants.NATCASH_WALLET_TICKET') {
  1104. showOtpModal(true);
  1105. return;
  1106. }
  1107. isSendingOtp = true;
  1108. const originalText = $(btn).html();
  1109. $(btn).prop('disabled', true).html('<i class="fa-solid fa-spinner fa-spin mr-2"></i>Processing...');
  1110. $("#paymentSourceModal").removeClass("hidden").addClass("flex");
  1111. }
  1112. function hidePaymentSourceModal() {
  1113. $("#paymentSourceModal").removeClass("flex").addClass("hidden");
  1114. }
  1115. function selectPaymentSource(paymentSource, btn) {
  1116. const originalText = $(btn).html();
  1117. const sourceButtons = $(".payment-source-button");
  1118. sourceButtons.prop('disabled', true);
  1119. $(btn).html('<i class="fa-solid fa-spinner fa-spin mr-2"></i>Processing...');
  1120. $.ajax({
  1121. url: subDomain + '@Url.Action("PrepareTicketPayment", "Home")',
  1122. type: 'POST',
  1123. contentType: 'application/json',
  1124. data: JSON.stringify({
  1125. paymentSource: paymentSource,
  1126. ticketData: pendingPaymentRequest
  1127. }),
  1128. success: function(data) {
  1129. sourceButtons.prop('disabled', false);
  1130. $(btn).html(originalText);
  1131. if (data.responseCode !== "0") {
  1132. showNotification(data.responseMessage || "Confirmation failed", data.responseCode);
  1133. return;
  1134. }
  1135. currentTransId = data.transId;
  1136. if (paymentSource === '@Constants.NATCASH_WALLET_TICKET') {
  1137. if (data.redirectUrl) {
  1138. window.location.href = data.redirectUrl;
  1139. } else {
  1140. showNotification(data.responseMessage || "Unable to open wallet payment.", "warning");
  1141. }
  1142. return;
  1143. }
  1144. sendOtpAfterTicketConfirmation();
  1145. },
  1146. error: function() {
  1147. sourceButtons.prop('disabled', false);
  1148. $(btn).html(originalText);
  1149. showNotification("Network error occurred.", "warning");
  1150. }
  1151. });
  1152. }
  1153. function sendOtpAfterTicketConfirmation() {
  1154. $.ajax({
  1155. url: subDomain + '@Url.Action("SendOTP", "Home")',
  1156. type: 'POST',
  1157. success: function(data) {
  1158. if (data.responseCode === "0") {
  1159. hidePaymentSourceModal();
  1160. showOtpModal();
  1161. showOtpModal(false);
  1162. } else {
  1163. showNotification(data.responseMessage || "Failed to send OTP", data.responseCode);
  1164. }
  1165. },
  1166. error: function() {
  1167. showNotification("Network error occurred.", "warning");
  1168. },
  1169. complete: function() {
  1170. isSendingOtp = false;
  1171. }
  1172. });
  1173. }
  1174. let otpInterval;
  1175. function showOtpModal(isWalletPin) {
  1176. hideOrderSummary();
  1177. $("#otpModal").removeClass("hidden").addClass("flex");
  1178. $("#otpInputs input").val("");
  1179. $("#walletPinInput").val("").attr("type", "password");
  1180. $("#walletPinEye").attr("class", "fa-solid fa-eye");
  1181. $("#otpConfirmBtn").prop('disabled', true);
  1182. $("#otpError").addClass("hidden").text("");
  1183. // Map game type to readable name & image
  1184. let gameTypeStr = "@Model.termType";
  1185. let displayName = gameTypeStr === "@Constants.Millions_CODE" ? "@Lang.millions" : "Basic Pick 10";
  1186. let imgSrc = "";
  1187. if (gameTypeStr === "@Constants.PIC10_BIGSMALL_CODE") {
  1188. // Get the specific choice from summary
  1189. let firstTicketText = $("#summaryTicketList").find("span.font-black").first().text().trim();
  1190. if (firstTicketText) {
  1191. displayName = firstTicketText.charAt(0).toUpperCase() + firstTicketText.slice(1).toLowerCase(); // Normalize to "Big" or "Small"
  1192. } else {
  1193. displayName = "Big / Small";
  1194. }
  1195. } else if (gameTypeStr === "@Constants.PIC10_ODDEVEN_CODE") {
  1196. let firstTicketText = $("#summaryTicketList").find("span.font-black").first().text().trim();
  1197. if (firstTicketText) {
  1198. displayName = firstTicketText.charAt(0).toUpperCase() + firstTicketText.slice(1).toLowerCase(); // Normalize to "Odd" or "Even"
  1199. } else {
  1200. displayName = "Odd / Even";
  1201. }
  1202. }
  1203. // Determine color based on game type
  1204. let typeColorClass = "text-purple-700"; // default
  1205. if (gameTypeStr === "@Constants.PIC10_BASIC_CODE") typeColorClass = "text-[#0062FF]";
  1206. else if (gameTypeStr === "@Constants.Millions_CODE") typeColorClass = "text-[#0062FF]";
  1207. else if (gameTypeStr === "@Constants.PIC10_BIGSMALL_CODE") typeColorClass = "text-[#0A9800]";
  1208. else if (gameTypeStr === "@Constants.PIC10_ODDEVEN_CODE") typeColorClass = "text-[#9333ea]";
  1209. // Hide image for now and use the beautiful text style as requested
  1210. $("#otpTicketTypeImg").hide();
  1211. $("#otpTicketTypeContainer").find("span").remove();
  1212. $("#otpTicketTypeContainer").append(`<span class='text-[17px] font-[900] ${typeColorClass} italic'>${displayName}</span>`);
  1213. $("#otpTotalAmount").text($("#summaryTotalAmount").text());
  1214. if (isWalletPin) {
  1215. $("#paymentCodeInstruction").text('@Html.Raw(Lang.payment_wallet_pin_instruction.Replace("'", "\\'"))');
  1216. $("#otpInputs").addClass("hidden");
  1217. $("#walletPinContainer").removeClass("hidden");
  1218. $("#otpTimer, #resendOtpBtn").addClass("hidden");
  1219. clearInterval(otpInterval);
  1220. $("#walletPinInput").focus();
  1221. } else {
  1222. $("#paymentCodeInstruction").text('@Html.Raw(Lang.millions_otp_instruction.Replace("'", "\\'"))');
  1223. $("#walletPinContainer").addClass("hidden");
  1224. $("#otpInputs").removeClass("hidden");
  1225. startOtpTimer(60);
  1226. $("#otp1").focus();
  1227. }
  1228. }
  1229. function updateWalletPinState() {
  1230. $("#otpConfirmBtn").prop('disabled', $("#walletPinInput").val().length === 0);
  1231. $("#otpError").addClass("hidden").text("");
  1232. }
  1233. function toggleWalletPinVisibility() {
  1234. const input = $("#walletPinInput");
  1235. const showPin = input.attr("type") === "password";
  1236. input.attr("type", showPin ? "text" : "password");
  1237. $("#walletPinEye").attr("class", showPin ? "fa-solid fa-eye-slash" : "fa-solid fa-eye");
  1238. input.focus();
  1239. }
  1240. // Add backspace support for OTP inputs
  1241. $("#otpInputs input").on("keyup", function() {
  1242. let otp = "";
  1243. $("#otpInputs input").each(function() { otp += $(this).val(); });
  1244. $("#otpConfirmBtn").prop('disabled', otp.length < 6);
  1245. });
  1246. $("#otpInputs input").on("keydown", function(e) {
  1247. if (e.key === "Backspace" && this.value.length === 0) {
  1248. $(this).prev('input').focus();
  1249. }
  1250. });
  1251. function hideOtpModal() {
  1252. $("#otpModal").removeClass("flex").addClass("hidden");
  1253. clearInterval(otpInterval);
  1254. }
  1255. function startOtpTimer(seconds) {
  1256. let timeLeft = seconds;
  1257. $("#resendOtpBtn").addClass("hidden");
  1258. $("#otpTimer").removeClass("hidden").text(timeLeft + "s");
  1259. clearInterval(otpInterval);
  1260. otpInterval = setInterval(() => {
  1261. timeLeft--;
  1262. $("#otpTimer").text(timeLeft + "s");
  1263. if (timeLeft <= 0) {
  1264. clearInterval(otpInterval);
  1265. $("#otpTimer").addClass("hidden");
  1266. $("#resendOtpBtn").removeClass("hidden");
  1267. }
  1268. }, 1000);
  1269. }
  1270. function moveToNext(el, nextId) {
  1271. if (el.value.length >= 1) {
  1272. if (nextId) document.getElementById(nextId).focus();
  1273. }
  1274. let otp = "";
  1275. $("#otpInputs input").each(function() { otp += $(this).val(); });
  1276. $("#otpConfirmBtn").prop('disabled', otp.length < 6);
  1277. // Clear error when typing
  1278. $("#otpError").addClass("hidden").text("");
  1279. }
  1280. function sendOtpRequest() {
  1281. // Re-trigger SendOTP
  1282. $.ajax({
  1283. url: subDomain + '@Url.Action("SendOTP", "Home")',
  1284. type: 'POST',
  1285. success: function(data) {
  1286. if (data.responseCode === "0") {
  1287. startOtpTimer(60);
  1288. showNotification("OTP has been resent.", "success");
  1289. } else {
  1290. showNotification(data.responseMessage || "Failed to resend OTP", data.responseCode);
  1291. }
  1292. }
  1293. });
  1294. }
  1295. function showReceiptSuccess(transId, amount, phone, totalTickets, drawDate) {
  1296. // Setup data dynamically
  1297. $("#receiptAmount").text(formatMoneyV2(amount) + " HTG");
  1298. if(phone) $("#receiptPhone").text(phone);
  1299. if(totalTickets) $("#receiptTotalTickets").text(totalTickets);
  1300. if(drawDate) $("#receiptDrawDate").text(drawDate);
  1301. let gameTypeStr = "@Model.termType";
  1302. let displayName = "Basic Pick 10";
  1303. if (gameTypeStr === "@Constants.PIC10_BIGSMALL_CODE") displayName = "@Lang.millions_big_small";
  1304. else if (gameTypeStr === "@Constants.PIC10_ODDEVEN_CODE") displayName = "@Lang.millions_odd_even";
  1305. else if (gameTypeStr === "@Constants.Millions_CODE") displayName = "Millions";
  1306. $("#receiptGameType").text("@Lang.buy " + displayName);
  1307. $("#receiptTicketCode").text("#" + transId);
  1308. let choiceText = "-";
  1309. if (gameTypeStr === "@Constants.PIC10_BIGSMALL_CODE" || gameTypeStr === "@Constants.PIC10_ODDEVEN_CODE") {
  1310. choiceText = $("#summaryTicketList .flex.items-center span.font-black").first().text().trim();
  1311. } else {
  1312. choiceText = gameTypeStr === "@Constants.Millions_CODE" ? "Millions" : "PICK 10";
  1313. }
  1314. $("#receiptChoice").text(choiceText);
  1315. // Format current date "dd/MM/yyyy - HH:mm:ss"
  1316. let now = new Date();
  1317. let ds = now.getDate().toString().padStart(2, '0') + '/' + (now.getMonth() + 1).toString().padStart(2, '0') + '/' + now.getFullYear() + ' - ' + now.getHours().toString().padStart(2, '0') + ':' + now.getMinutes().toString().padStart(2, '0') + ':' + now.getSeconds().toString().padStart(2, '0');
  1318. $("#receiptTime").text(ds);
  1319. hideOtpModal();
  1320. $("#receiptSuccessModal").removeClass("hidden").addClass("flex");
  1321. }
  1322. function finalizePurchase(btn) {
  1323. if (isFinalizingPurchase) return;
  1324. const isWalletPayment = currentChannelPayment === '@Constants.NATCASH_WALLET_TICKET';
  1325. let otpCode = isWalletPayment ? $("#walletPinInput").val().trim() : "";
  1326. if (!isWalletPayment) {
  1327. $("#otpInputs input").each(function() { otpCode += $(this).val(); });
  1328. }
  1329. if ((isWalletPayment && otpCode.length === 0) || (!isWalletPayment && otpCode.length < 6)) {
  1330. showNotification(isWalletPayment ? '@Html.Raw(Lang.payment_wallet_pin_instruction.Replace("'", "\\'"))' : "Please enter full 6-digit OTP", "warning");
  1331. return;
  1332. }
  1333. isFinalizingPurchase = true;
  1334. const originalText = $(btn).html();
  1335. $(btn).prop('disabled', true).html('<i class="fa-solid fa-spinner fa-spin mr-2"></i> ...');
  1336. if (isWalletPayment) {
  1337. submitFinalPurchase(btn, originalText, true, otpCode);
  1338. return;
  1339. }
  1340. // Confirm the OTP first. The final purchase API is called only after
  1341. // this request succeeds for the current prepared transaction.
  1342. $.ajax({
  1343. url: subDomain + '@Url.Action("ConfirmOTP", "Home")',
  1344. type: 'POST',
  1345. contentType: 'application/json',
  1346. data: JSON.stringify({
  1347. otp: otpCode,
  1348. transIdByTicket: currentTransId
  1349. }),
  1350. success: function(otpResult) {
  1351. if (otpResult.responseCode === "0" || otpResult.responseCode === "0000") {
  1352. submitFinalPurchase(btn, originalText, false, null);
  1353. return;
  1354. }
  1355. $(btn).prop('disabled', false).html(originalText);
  1356. isFinalizingPurchase = false;
  1357. $("#otpError").text(otpResult.responseMessage || "Invalid OTP").removeClass("hidden");
  1358. $("#otpInputs input").val("");
  1359. $("#otp1").focus();
  1360. },
  1361. error: function() {
  1362. $(btn).prop('disabled', false).html(originalText);
  1363. isFinalizingPurchase = false;
  1364. showNotification("Network error occurred during OTP verification.", "warning");
  1365. }
  1366. });
  1367. }
  1368. function submitFinalPurchase(btn, originalText, isWalletPayment, walletPin) {
  1369. const finalData = {
  1370. transIdByTicket: currentTransId,
  1371. gameId: isFreeTicketMode ? "@Constants.Millions_CODE" : "@Model.termType",
  1372. paymentCode: null,
  1373. walletPin: isWalletPayment ? walletPin : null,
  1374. channelPayment: currentChannelPayment
  1375. };
  1376. // This final API is unreachable until ConfirmOTP succeeds (or a wallet PIN is supplied).
  1377. $.ajax({
  1378. url: subDomain + '@Url.Action("ConfirmBuyingTicketV2", "Home")',
  1379. type: 'POST',
  1380. contentType: 'application/json',
  1381. data: JSON.stringify(finalData),
  1382. success: function(res) {
  1383. $(btn).prop('disabled', false).html(originalText);
  1384. if (res.responseCode === "0" || res.responseCode === "0000") {
  1385. // Success: Show receipt Modal
  1386. showReceiptSuccess(res.orderId || currentTransId, $("#summaryTotalAmount").text(), "@(Model.userStatus?.msisdn ?? "-")", $("#summaryTotalCount").text(), "@(currentTerm?.date_random ?? "-")");
  1387. } else {
  1388. if (res.responseCode === "-2" || (res.responseMessage && res.responseMessage.includes("System is upgrading"))) {
  1389. hideOtpModal();
  1390. showNotification(res.responseMessage || "System is upgrading", res.responseCode);
  1391. } else {
  1392. $("#otpError").text(res.responseMessage || "Invalid OTP").removeClass("hidden");
  1393. if (isWalletPayment) {
  1394. $("#walletPinInput").val("").focus();
  1395. } else {
  1396. $("#otpInputs input").val("");
  1397. $("#otp1").focus();
  1398. }
  1399. }
  1400. }
  1401. },
  1402. error: function() {
  1403. $(btn).prop('disabled', false).html(originalText);
  1404. showNotification("Network error occurred during payment completion.", "warning");
  1405. },
  1406. complete: function() {
  1407. isFinalizingPurchase = false;
  1408. }
  1409. });
  1410. }
  1411. var systemUpgrading = false;
  1412. function showNotification(message, code) {
  1413. const msgEl = $("#notificationMessage");
  1414. const iconEl = $("#notificationModal img");
  1415. const btnEl = $("#notificationModal button");
  1416. if (message && message.includes("\n")) {
  1417. msgEl.html(message.replace(/\n/g, '<br/>'));
  1418. } else {
  1419. msgEl.text(message);
  1420. }
  1421. if (code === "-2" || (message && message.includes("System is upgrading"))) {
  1422. systemUpgrading = true;
  1423. btnEl.text("@Lang.login");
  1424. } else {
  1425. systemUpgrading = false;
  1426. btnEl.text("OK");
  1427. }
  1428. // Toggle icon based on type (warning or success)
  1429. const warningIcon = '/Millions/img/modal/warning_icon.png';
  1430. const successIcon = '/Millions/img/modal/success_icon_v2.png';
  1431. const fallbackWarning = 'https://cdn-icons-png.flaticon.com/512/564/564619.png';
  1432. const fallbackSuccess = 'https://cdn-icons-png.flaticon.com/512/190/190411.png';
  1433. if (code === "-2" || code === "warning" || code === "error") {
  1434. iconEl.attr('src', warningIcon);
  1435. iconEl.attr('onerror', `this.src='${fallbackWarning}'`);
  1436. } else {
  1437. iconEl.attr('src', successIcon);
  1438. iconEl.attr('onerror', `this.src='${fallbackSuccess}'`);
  1439. }
  1440. $("#notificationModal").removeClass("hidden").addClass("flex");
  1441. }
  1442. function closeNotificationModal() {
  1443. $("#notificationModal").addClass("hidden").removeClass("flex");
  1444. if (systemUpgrading) {
  1445. window.location.href = subDomain + "/Account/Login";
  1446. }
  1447. }
  1448. // ====== CARD SELECTION GAME LOGIC (BIG/SMALL / ODD/EVEN) ======
  1449. var bsChoice = null; // 'big' or 'small' (reused as 'odd' or 'even')
  1450. const isBigSmall = @(Model.termType == Constants.PIC10_BIGSMALL_CODE ? "true" : "false");
  1451. const themeColor = isBigSmall ? "#0A9800" : "#AA3DC8";
  1452. const labelBig = isBigSmall ? "Big" : "Odd";
  1453. const labelSmall = isBigSmall ? "Small" : "Even";
  1454. const colorBig = isBigSmall ? "#A2FF00" : "#FFC700";
  1455. const colorSmall = isBigSmall ? "#FF4157" : "#B33BD0";
  1456. // Loclized text from resources
  1457. const langSelect = "@Lang.millions_select";
  1458. const langSelected = "@Lang.millions_selected";
  1459. function selectBigSmall(choice) {
  1460. bsChoice = choice;
  1461. var cardBig = document.getElementById('cardBig');
  1462. var cardSmall = document.getElementById('cardSmall');
  1463. var choiceDisplay = document.getElementById('choiceDisplay');
  1464. if (!cardBig || !cardSmall) return;
  1465. if (choice === 'big') {
  1466. // Highlight Big/Odd card with theme glow
  1467. cardBig.style.border = '2px solid ' + themeColor;
  1468. cardBig.style.boxShadow = '0px 0px 12px 0px ' + (isBigSmall ? 'rgba(162, 255, 0, 1)' : 'rgba(179, 59, 208, 0.6)');
  1469. cardBig.querySelector('.bigsmall-btn').textContent = langSelected;
  1470. cardBig.querySelector('.bigsmall-btn').style.background = '#333';
  1471. // Reset Small/Even card
  1472. cardSmall.style.border = '2px solid transparent';
  1473. cardSmall.style.boxShadow = 'none';
  1474. cardSmall.querySelector('.bigsmall-btn').textContent = langSelect;
  1475. cardSmall.querySelector('.bigsmall-btn').style.background = themeColor;
  1476. // Update display
  1477. if (choiceDisplay) {
  1478. choiceDisplay.textContent = labelBig;
  1479. choiceDisplay.style.color = colorBig;
  1480. choiceDisplay.style.webkitTextStroke = '1px #000';
  1481. }
  1482. } else {
  1483. // Highlight Small/Even card with theme glow
  1484. cardSmall.style.border = '2px solid ' + themeColor;
  1485. cardSmall.style.boxShadow = '0px 0px 12px 0px ' + (isBigSmall ? 'rgba(162, 255, 0, 1)' : 'rgba(179, 59, 208, 0.6)');
  1486. cardSmall.querySelector('.bigsmall-btn').textContent = langSelected;
  1487. cardSmall.querySelector('.bigsmall-btn').style.background = '#333';
  1488. // Reset Big/Odd card
  1489. cardBig.style.border = '2px solid transparent';
  1490. cardBig.style.boxShadow = 'none';
  1491. cardBig.querySelector('.bigsmall-btn').textContent = langSelect;
  1492. cardBig.querySelector('.bigsmall-btn').style.background = themeColor;
  1493. // Update display
  1494. if (choiceDisplay) {
  1495. choiceDisplay.textContent = labelSmall;
  1496. choiceDisplay.style.color = colorSmall;
  1497. choiceDisplay.style.webkitTextStroke = '1px #000';
  1498. }
  1499. }
  1500. $("#bsTotalTicketCount").text(1);
  1501. $("#bsTotalPrice").text(formatMoneyV2(50));
  1502. }
  1503. function bsShowPayment(e) {
  1504. preparePayment(e);
  1505. }
  1506. </script>
  1507. <!-- Number Picker Modal (Refined Bottom Sheet) -->
  1508. <div id="numberPickerModal" class="fixed inset-0 bg-black/10 z-[200] hidden items-end justify-center p-0 transition-all">
  1509. <div class="modal-content bg-white w-full md:max-w-[414px] mx-auto shadow-2xl animate__animated animate__slideInUp animate__faster rounded-t-[20px] overflow-hidden">
  1510. <div class="px-4 py-1.5 bg-[#0062FF] text-white flex justify-between items-center relative">
  1511. <div class="flex flex-col">
  1512. <h3 class="font-black text-[15px] uppercase tracking-wide" id="modalTitle">@Lang.Pick_Number</h3>
  1513. <div class="selection-count-area">
  1514. <span class="text-[10px] font-bold text-white/80 uppercase">Selected: <span id="selectionCount" class="text-white">0</span>/<span id="maxSelectionCount">10</span></span>
  1515. </div>
  1516. </div>
  1517. <button onclick="closeNumberPicker()" class="w-8 h-8 flex items-center justify-center rounded-full bg-white/10 hover:bg-white/20 transition-all">
  1518. <i class="fa-solid fa-xmark text-lg"></i>
  1519. </button>
  1520. </div>
  1521. <style>
  1522. #numberGrid::-webkit-scrollbar { width: 3px; }
  1523. #numberGrid::-webkit-scrollbar-track { background: transparent; }
  1524. #numberGrid::-webkit-scrollbar-thumb { background: #FFD700; border-radius: 10px; }
  1525. #numberGrid { scrollbar-width: thin; scrollbar-color: #FFD700 transparent; }
  1526. </style>
  1527. <div class="p-2 h-[220px] overflow-hidden bg-gray-50 border-b" id="numberGrid">
  1528. <!-- Populated via JS -->
  1529. </div>
  1530. <div class="p-3 bg-white border-t flex gap-3">
  1531. <button onclick="closeNumberPicker()" class="flex-1 py-1 bg-gray-100 text-gray-600 rounded-lg font-black text-[12px] active:bg-gray-200 transition-all uppercase">
  1532. @Lang.millions_back
  1533. </button>
  1534. <button id="confirmBtn" class="hidden flex-[2] py-2 bg-[#0062FF] text-white rounded-lg font-black text-[13px] active:bg-[#CC002D] transition-all uppercase shadow-md">
  1535. @Lang.confirm
  1536. </button>
  1537. </div>
  1538. </div>
  1539. </div>
  1540. <div id="notificationModal" class="fixed inset-0 z-[300] bg-black/60 flex items-center justify-center hidden px-4 font-bricolage backdrop-blur-sm">
  1541. <div class="w-full max-w-[360px] bg-white rounded-[32px] overflow-hidden flex flex-col items-center px-6 pt-5 pb-6 animate__animated animate__zoomIn animate__faster shadow-2xl relative border border-white/50">
  1542. <!-- Alert Icon -->
  1543. <div class="w-full flex justify-center mb-2 mt-0">
  1544. <img src="/Millions/img/modal/success_icon_v2.png" class="w-full max-w-[240px] h-auto object-contain" alt="Notificaton icon" onerror="this.src='https://cdn-icons-png.flaticon.com/512/190/190411.png'" />
  1545. </div>
  1546. <!-- Message Area -->
  1547. <div class="px-2 text-center mb-5">
  1548. <p id="notificationMessage" class="text-black font-[800] text-[17px] leading-snug">
  1549. <!-- Message content -->
  1550. </p>
  1551. </div>
  1552. <!-- Action Button -->
  1553. <div class="w-full">
  1554. <button onclick="closeNotificationModal()" class="w-full bg-[#0062FF] text-white font-[900] text-[18px] py-[13px] rounded-[18px] shadow-[0_8px_20px_rgba(238,0,51,0.25)] active:scale-95 transition-all uppercase tracking-wide">
  1555. OK
  1556. </button>
  1557. </div>
  1558. </div>
  1559. </div>
  1560. <!-- Beautiful Success Receipt Modal (Matches Figma 161:3722) -->
  1561. <div id="receiptSuccessModal" class="fixed inset-0 z-[300] bg-black/80 hidden items-center justify-center px-4 font-bricolage backdrop-blur-md">
  1562. <div class="w-full max-w-[360px] bg-[#F9F9F9] rounded-[32px] overflow-hidden flex flex-col items-center px-6 pt-4 pb-5 shadow-2xl relative animate__animated animate__zoomIn animate__faster border border-white/50">
  1563. <!-- Confetti/Celebration background effect (Subtle removed) -->
  1564. <h2 class="text-[#534A4A] font-[800] text-[19px] tracking-tight relative z-10 w-full text-center mt-1">@Lang.millions_payment_successfully</h2>
  1565. <!-- Ticket / Success Graphic -->
  1566. <div class="relative w-full flex justify-center mt-2 mb-0 z-10 px-4">
  1567. <img src="/Millions/img/modal/success_icon_v2.png" alt="Success" class="w-full h-auto object-contain">
  1568. </div>
  1569. <h3 class="text-[#0A9800] font-[900] text-[20px] uppercase tracking-wide relative z-10">@Lang.success</h3>
  1570. <div class="w-full h-px border-t-[2px] border-dashed border-gray-300 my-3 relative z-10"></div>
  1571. <div class="w-full flex justify-between items-center mb-2 relative z-10 px-1">
  1572. <span class="text-[#534A4A] font-bold text-[14px]">@Lang.phone_number</span>
  1573. <span class="font-black text-[14px] text-gray-800" id="receiptPhone">-</span>
  1574. </div>
  1575. <div class="w-full flex justify-between items-center mb-2 relative z-10 px-1">
  1576. <span class="text-[#534A4A] font-bold text-[14px]">@Lang.millions_your_choice</span>
  1577. <span class="text-[#0062FF] font-[900] text-[15px] uppercase" id="receiptChoice">-</span>
  1578. </div>
  1579. <div class="w-full flex justify-between items-center mb-2 relative z-10 px-1">
  1580. <span class="text-[#534A4A] font-bold text-[14px]">@Lang.ticket_code</span>
  1581. <span class="font-black text-[13px] text-gray-800" id="receiptTicketCode">#</span>
  1582. </div>
  1583. <div class="w-full flex justify-between items-center mb-2 relative z-10 px-1">
  1584. <span class="text-[#534A4A] font-bold text-[14px]">@Lang.total_ticket</span>
  1585. <span class="font-black text-[14px] text-gray-800" id="receiptTotalTickets">-</span>
  1586. </div>
  1587. <div class="w-full flex justify-between items-center mb-2 relative z-10 px-1">
  1588. <span class="text-[#534A4A] font-bold text-[14px]">@Lang.millions_draw_date</span>
  1589. <span class="font-black text-[14px] text-gray-800" id="receiptDrawDate">-</span>
  1590. </div>
  1591. <div class="w-full flex justify-between items-center mb-1 relative z-10 px-1">
  1592. <span class="text-[#534A4A] font-bold text-[14px]">@Lang.total_payment</span>
  1593. <span class="text-[#0062FF] font-[900] text-[15px]" id="receiptAmount">0 HTG</span>
  1594. </div>
  1595. <div class="w-full h-px border-t-[2px] border-dashed border-gray-300 my-3 relative z-10"></div>
  1596. <div class="w-full flex justify-between items-center mb-2 relative z-10 px-1">
  1597. <span class="text-[#534A4A] font-bold text-[14px]">@Lang.time</span>
  1598. <span class="font-bold text-[13px] text-gray-600" id="receiptTime">00:00:00</span>
  1599. </div>
  1600. <div class="w-full flex justify-start items-center relative z-10 px-1 mt-1">
  1601. <span class="text-[#534A4A] font-bold text-[13px] italic text-gray-500" id="receiptGameType">@Lang.millions_buy_ticket_label</span>
  1602. </div>
  1603. <div class="text-[#534A4A] font-[900] text-[18px] relative z-10 text-center mt-3">@Lang.thank_you <span class="text-[#0062FF]">♥️</span></div>
  1604. <div class="w-full flex gap-2.5 mt-4 relative z-10">
  1605. <button type="button" onclick="window.location.href = subDomain + '@Url.Action("BuyTicket", "Home", new { termType = Model.termType })';" class="flex-1 min-w-0 border-2 border-[#0062FF] bg-white text-[#0062FF] font-[900] text-[15px] py-3 rounded-[18px] active:scale-95 transition-all uppercase tracking-wide shadow-sm">
  1606. @Lang.millions_continue
  1607. </button>
  1608. <button type="button" onclick="window.location.href = subDomain + '@Url.Action("GameHome", "Home", new { termType = Model.termType })';" class="flex-1 min-w-0 bg-[#0062FF] text-white font-[900] text-[15px] py-3 rounded-[18px] shadow-[0_8px_20px_rgba(0,98,255,0.25)] active:scale-95 transition-all uppercase tracking-wide">
  1609. @Lang.close
  1610. </button>
  1611. </div>
  1612. </div>
  1613. </div>
  1614. }