<?php
function ftab($db_stat, $tname, $colname)
{
  require 'data.php';

  $fdb = "SELECT " . $db_stat . " FROM " . $tname . " LIMIT 1";
  $qdb = mysqli_query($data, $fdb);

  if (mysqli_num_rows($qdb) > 0) {
    $fetch = mysqli_fetch_assoc($qdb);
    return html_entity_decode($fetch[$colname]);
  }
}


function fwtab($db_stat, $tname, $colname, $cond1, $cond2)
{
  require 'data.php';

  $fdb = "SELECT " . $db_stat . " FROM " . $tname . " WHERE " . $cond1 . " = '" . $cond2 . "' ";
  $qdb = mysqli_query($data, $fdb);

  if (mysqli_num_rows($qdb) > 0) {
    $fetch = mysqli_fetch_assoc($qdb);
    return html_entity_decode($fetch[$colname]);
  }
}

function liveDraw($lang, $token, $date, $hadiah, $prize1, $prize2, $prize3)
{

  if ($lang == 'en') {
    return '
    <h4 class="text-end">Ticket: #' . $token . '</h4>
  <div class="d-lg-flex align-items-center justify-content-between my-3">
  <h4 class="text-uppercase"><span class="day-card">' . date("l", strtotime($date)) . ',</span> ' . date("d F Y", strtotime($date)) . '</h4>
    <h2>Jackpot : ₫' . $hadiah . '</h2>
</div>

<div class="row align-items-center">
  <div class="col-lg-4 text-center">
      <h2 class="fw-bold">Hot Prize</h2>
  </div>

  <div class="col-lg-8 text-center">
          <ul class="ball-draw">
              ' . $prize1 . '
          </ul>
  </div>

  <div class="col-lg-4 text-center">
      <h2 class="fw-bold">Spotlight Prize</h2>
  </div>

  <div class="col-lg-8 text-center">
          <ul class="ball-draw">
            ' . $prize2 . '
          </ul>
  </div>

  <div class="col-lg-4 text-center">
      <h2 class="fw-bold">Dashing Prize</h2>
  </div>

  <div class="col-lg-8 text-center">
          <ul class="ball-draw">
            ' . $prize3 . '
          </ul>
  </div>';
  } else {

    return '
    <h4 class="text-end">Vé: #' . $token . '</h4>
  <div class="d-lg-flex align-items-center justify-content-between my-3">
  <h4 class="text-uppercase"><span class="day-card">' . date("l", strtotime($date)) . ',</span> ' . date("d F Y", strtotime($date)) . '</h4>
    <h2>giải đặc biệt: ₫' . $hadiah . '</h2>
</div>

<div class="row align-items-center">
  <div class="col-lg-4 text-center">
      <h2 class="fw-bold">Giải thưởng nóng</h2>
  </div>

  <div class="col-lg-8 text-center">
          <ul class="ball-draw">
              ' . $prize1 . '
          </ul>
  </div>

  <div class="col-lg-4 text-center">
      <h2 class="fw-bold">Giải tiêu điểm</h2>
  </div>

  <div class="col-lg-8 text-center">
          <ul class="ball-draw">
            ' . $prize2 . '
          </ul>
  </div>

  <div class="col-lg-4 text-center">
      <h2 class="fw-bold">Giải thưởng rạng ngời</h2>
  </div>

  <div class="col-lg-8 text-center">
          <ul class="ball-draw">
            ' . $prize3 . '
          </ul>
  </div>';
  }
}

function resultCard($date, $prize1, $hadiah, $lang)
{

  if ($lang == 'en') {

    return '<div class="result-card shadow">
    <div class="d-lg-flex align-items-center justify-content-between my-3">
        <h4 class="text-uppercase"><span class="day-card">' . date("l", strtotime($date)) . ',</span> ' . date("d F Y", strtotime($date)) . '</h4>
    <button onclick="pageUrl(\'result\')" class="btn-result"><i class="fas fa-receipt"></i> Check Results</button>
    </div>

    <div class="row align-items-center">
          <div class="col-lg-4 text-center">
              <h2>Jackpot : ₫' . $hadiah . '</h2>
          </div>

          <div class="col-lg-8 text-center">
                  <ul class="ball-draw">
                      ' . $prize1 . '
                  </ul>
          </div>
    </div>
    </div>';
  } else {

    return '<div class="result-card shadow">
    <div class="d-lg-flex align-items-center justify-content-between my-3">
        <h4 class="text-uppercase"><span class="day-card">' . date("l", strtotime($date)) . ',</span> ' . date("d F Y", strtotime($date)) . '</h4>
    <button onclick="pageUrl(\'result\')" class="btn-result"><i class="fas fa-receipt"></i> Kiểm tra kết quả</button>
    </div>

    <div class="row align-items-center">
          <div class="col-lg-4 text-center">
              <h2>giải đặc biệt: ₫' . $hadiah . '</h2>
          </div>

          <div class="col-lg-8 text-center">
                  <ul class="ball-draw">
                      ' . $prize1 . '
                  </ul>
          </div>
    </div>
    </div>';
  }
}
