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

<div class="card" id="primary-card">
    <div class="card-header ui-sortable-handle" style="cursor: move">
        <h2 class="card-title" style="font-size: 2.5rem;" id="FinancialReportsDailyTargetDate">Financial Reports (Daily)
        </h2>

        <div class="card-tools">
            <input type="date" class="form-control" id="FinancialReportsDailyTargetDateSelect">
        </div>
    </div>
    <div class="card-body">
        <table id="accounting_reports_list_table">
            <thead>

            </thead>
            <tbody>
                <tr>
                    <td>
                        <h4>Total Bet Amount </h4>
                    </td>
                    <td>
                        <h4 id="totalbetamountfield_AccountingFinancialReportDaily">+</h4>
                    </td>
                </tr>
                <tr>
                    <td>
                        <h4>Commission for Team Players (15%)</h4>
                    </td>
                    <td>
                        <h4 id="commissionamountplayer_AccountingFinancialReportDaily">-</h4>
                    </td>
                </tr>
                <tr>
                    <td>

                    </td>
                    <td>
                        <b>
                            <h4 id="BetAmountMinusCommissionPlayers_AccountingFinancialReportDaily"></h4>
                        </b>
                    </td>
                </tr>
                <tr>
                    <td>

                    </td>
                    <td>
                        <h4 id=""></h4>
                    </td>
                </tr>
                <tr>
                    <td>
                        <h4>Total Prizes to Dispense</h4>
                    </td>
                    <td>
                        <h4 id="totalprizesamountfield_AccountingFinancialReportDaily">-</h4>
                    </td>
                </tr>

                <tr id='NetRevenueRowAccountFinancialReportsDaily'>
                    <td>
                        <h4><b id="NetRevenueLabel">Net Revenue</b></h4>
                    </td>
                    <td>
                        <b>
                            <h4 id="NetRevenueAmountfield_AccountingFinancialReportDaily"></h4>
                        </b>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

<br><br><br>
<script>

    if (typeof targetdate === 'undefined' || targetdate === null) {
        targetdate = '';
    }




    function GenerateDailyAccountingFinancialReportsNow(response) {

        if (typeof currenttarget === 'object' && currenttarget.hasOwnProperty('targetdate')) {
            targetdate = currenttarget['targetdate'];
        }

        if (typeof currenttarget === 'object' && currenttarget.hasOwnProperty('currenttarget')) {
            currenttarget = currenttarget['currenttarget'];
        }



        if (typeof targetdate === 'undefined' || targetdate === null || !targetdate) {
            targetdate = getDateInGMT8();
            targetdateObject = new Date(getDateInGMT8());
        } 
            targetdateObject = new Date(targetdate);
        

        texttargetdate = formatDate(targetdateObject);

        

        commissionprizeplayer = response.totalbetamount * 0.15;
 

        betMinusCommission = response.totalbetamount - commissionprizeplayer;

        

        NetRevenueAmount = betMinusCommission - response.totalamountofprizes;
   
        
        if (NetRevenueAmount < 0) {
            $('#NetRevenueLabel').html('Net Loss');
            $('#NetRevenueAmountfield_AccountingFinancialReportDaily').css('color', 'red');
            $('#NetRevenueRowAccountFinancialReportsDaily').css('color', 'red');

            $('#NetRevenueRowAccountFinancialReportsDaily').css('border', '2px solid red');
        } else {
            $('#NetRevenueLabel').html('Net Gain');
            $('#NetRevenueAmountfield_AccountingFinancialReportDaily').css('color', 'black');
            $('#NetRevenueRowAccountFinancialReportsDaily').css('color', 'black');

            $('#NetRevenueRowAccountFinancialReportsDaily').css('border', '2px solid black');
        }

        commissionprizeplayer = formatCurrency(commissionprizeplayer);
        betMinusCommission = formatCurrency(betMinusCommission);
        NetRevenueAmount = formatCurrency(NetRevenueAmount);
        totalbetamount = formatCurrency(response.totalbetamount);
        totalamountofprizes = formatCurrency(response.totalamountofprizes);

        $('#FinancialReportsDailyTargetDate').html('Financial Reports for ' + texttargetdate);

        $('#totalbetamountfield_AccountingFinancialReportDaily').html('+ ' + totalbetamount);
        $('#totalprizesamountfield_AccountingFinancialReportDaily').html('- ' + totalamountofprizes);
        
        $('#commissionamountplayer_AccountingFinancialReportDaily').html('- ' + commissionprizeplayer);

       
        $('#BetAmountMinusCommissionPlayers_AccountingFinancialReportDaily').html(' &nbsp<b>' + betMinusCommission + '</b>');


        
        $('#NetRevenueAmountfield_AccountingFinancialReportDaily').html(' &nbsp<b>' + NetRevenueAmount + '</b>');

     



    }



    function GenerateAccountFinancialReportDaily() {
        AjaxDo('?Accounting/FinancialReport/Daily', { targetdate: targetdate, currenttarget: currenttarget }, GenerateDailyAccountingFinancialReportsNow, null, reqtype = 'POST');
    }


    GenerateAccountFinancialReportDaily();


     TargetdateInput = document.getElementById('FinancialReportsDailyTargetDateSelect');


    TargetdateInput.value = getDateInGMT8();

    TargetdateInput.addEventListener('change', function () {
        targetdate = TargetdateInput.value;
        GenerateAccountFinancialReportDaily();

    });



</script>


<style>
    table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 20px;
    }

    th,
    td {
        border: 1px solid #ddd;
        padding: 8px;
        text-align: left;
    }

    th {
        background-color: #f2f2f2;
    }
</style>