BuyTicket.cshtml 87 KB

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