<br><br><br><br>

<div class="card" id="primary-card">
    <div class="card-header ui-sortable-handle" style="cursor: move">
        <h1 class="card-title" style="font-size: 2.5rem;">Daily Bets</h1>
        <div class="card-tools">
        </div>
    </div>
    <div class="card-body">
        <table id="Daily_bets_table">
            <thead>
                <tr>
                    <th>
                        User
                    </th>
                    <th>
                        Type
                    </th>
                    <th>
                        Amount
                    </th>
                    <th>
                        Prize
                    </th>
                </tr>
            </thead>
            <tbody>

            </tbody>
        </table>
    </div>
</div>

<brb><br><br>

    <script>

function GenerateDailyBetsRow(User,Type, Bet_Amount, Prize) {


return `<tr>
<td>${User}</td>
<td>${Type}</td>
<td>${Bet_Amount}</td>
<td>${Prize}</td>
</tr>`;
}




async function GenerateDailyBetsRows(responsearray) {
console.log(responsearray);
let newhtmltable = '';


for (let i = 0; i < responsearray.length; i++) {
    
    newhtmltable += GenerateDailyBetsRow(
        responsearray[i]['date'],
        responsearray[i]['user'],
        responsearray[i]['type'],
        responsearray[i]['amount'],
        responsearray[i]['prize']
    );
}

//$("#User_list_table").find("tbody").replaceWith(newhtmltable);
// new DataTable('#User_list_table');


$("#Daily_bets_table").find("tbody").html(newhtmltable);
//$("#Last30DaysTotalBetAmount").html(totalbetamount);
//$("#Last30DaysTotalPrizesAmount").html(totalprizes);

new DataTable('#Daily_bets_table', {
    language: {
        emptyTable: 'No Data Loaded'
    },
    order: [[0, 'desc']],
    "bDestroy": true
});





}


function GenerateDailyBetsTable() {

AjaxDo('?Reports/DailyBets/List', { targetuser: currenttarget }, GenerateDailyBetsRows, null, reqtype = 'POST');
}



GenerateDailyBetsTable();

setInterval(function () {
if (currentPage == 'DailyBets') {
    GenerateDailyBetsTable();
}
}, 300000);


    </script>