

<br><br><br><br>
<table class="" id="bets_history_table">
    <thead>
        <tr>
            <th>Date</th>
            <th>
                <center>Type</center>
            </th>
            <th>Draw</th>
            <th>Numbers</th>
            <th>Amount</th>
            <th></th>

        </tr>
    </thead>
    <tbody>

    </tbody>
</table>
<br><br><br>

<script>

document.body.style.zoom = 1;


    function GenerateBTRow(Date, Type, DrawTime, Num,Amount, Hashkey, Stat) {

        //const actionbutton =`<button class="btn btn-warning" onclick="gotoPage('bet_qr','${Hashkey}')">View<br>QR</button>`;
        const actionbutton = `<img src="assets/qrcode.svg" onclick="gotoPage('bet_qr','${Hashkey}')">`;
        return `<tr>
      <td style="">${Date}</td>
      <td style=""><center>${Type}</center></td>
      <td style="">${DrawTime}</td>
      <td style="padding-right: 0;">${Num}</td>
      <td style="padding-right: 0;">${Amount}</td>
      <td style=""><center>${actionbutton}</center></td>`  +
            //`<td style="padding: 0px;">${Stat}</td>`+
            `</tr>`;
    }




    async function GenerateBTRows(responsearray) {
       
        let newhtmltable = '';

        for (let i = 0; i < responsearray.length; i++) {
            const currentgametype = responsearray[i]['bet_type'];
            let currentgametypename = '';

            if (Object.keys(bet_types).length === 0) {
                await queryBetTypes();
                
            }


        currentgametypename = bet_types[currentgametype];
        if (currentgametypename === undefined){continue;}
           currentgametypename = currentgametypename.replace(' ', "<br>");
            currentgametypename = currentgametypename.replace(' ', "<br>");
            let cr_bet_date = responsearray[i]['bet_date'];
            let cr_bet_schedule = responsearray[i]['bet_schedule'];
            let current_bet_number = responsearray[i]['bet_number'];
            let current_bet_amount = responsearray[i]['amount'];
            if (current_bet_number.endsWith("-")) { current_bet_number = current_bet_number.slice(0, -1); }



            cr_bet_date = cr_bet_date.replace(' ', "<br>");
            cr_bet_schedule = cr_bet_schedule.replace(' ', "<br>");



            newhtmltable += GenerateBTRow(
                cr_bet_date,
                currentgametypename,
                cr_bet_schedule,
                current_bet_number,
                current_bet_amount,
                responsearray[i]['transactionID'],
                ''
            );
        }

        $("#bets_history_table").find("tbody").html(newhtmltable);
       let bethistorytable =  $("#bets_history_table").DataTable({
            order: [[0, 'desc']],
            pageLength: 5,
            lengthMenu: [[5], [5]]
        });
        $("#bets_history_table_length").hide();
        // new DataTable('#bets_history_table');

        bethistorytable.on('click', 'tbody tr', function () {
    let data = bethistorytable.row(this).data();
    let targettranshash = data[5];
    $(targettranshash).find('img').trigger('click');
    
});
    }

    
  function loaddashboardcard(response){
    total_balance = response.total_balance;
  $( "#total-balance" ).html(response.total_balance);
  //  $( "#pending-credit" ).html(data.total_credit);
    $( "#phone-number" ).html(response.number);
  }


  function loaduserdatadashboard(){AjaxDo('?userdatadashboard',null,loaddashboardcard, null,reqtype='GET');}

    function GenerateBTTable() {
        // if (!currenttarget){return false;}
        const dataRight = { user: currenttarget };
        AjaxDo('?user/bet/history', dataRight, GenerateBTRows, null, reqtype = 'POST');
    }


    GenerateBTTable();

    $(window).on('load', function () {
        //$('body').css('transform', 'scale(0.8)');
    });
    //$('html, body').css('overflow', 'hidden');

</script>