BuyTicket.cshtml 86 KB

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