
<style>
    .table thead tr >th{
        background-color:#4c0870;

        color:#fff;
    }
    .table thead tr th[class*='sorting_'] {
        color: #fff;
    }
    .bg-master-lighter {
        border:none;
        background-color:#fff;
        border-top:1px solid #ddd;  
    }
    .ValSpan {
        opacity:0;
    }
    .datepicker thead tr .dow {
        color:#ed9421 !important;
    }
    .datepicker table tr td.day:hover {
        background: #ed9421 !important;
        color:#fff;
    }
    .datepicker table tr td.active {
        background-color: #ed9421 !important;
    }
    .datepicker thead tr .datepicker-switch {
        color: #ed9421 !important;
        font-size: 13px;
    }
    .datepicker table tr td span.active {
        background-color: #ed9421 !important;
    }
    .datepicker table tr td span:hover {
        background-color: #ed9421 !important;
        color:#fff;
    }
    datepicker thead tr .next:before, .datepicker thead tr .prev:before {
        color: #ed9421 !important;
        font-family: 'FontAwesome';
        font-size: 10px;
    }
    .dropdown-menu>li>a{
        opacity: 1;
        color: #000;
        cursor: pointer
    }
    .HideMe{
        display: none
    } 

</style>
<script>
    function AddCommas(val) {
        val = parseFloat(val.toString()).toString();
        while (/(\d+)(\d{3})/.test(val.toString())) {
            val = val.toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2');
        }
        return val.replace(/\.0$|\.00$/, "") || "0";
    }
    function FixNumber(val) {
        return AddCommas(parseFloat(val + "").toFixed(2));
    }
</script>
<div class="container-fluid container-fixed-lg bg-white">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div class="panel-title pull-left"><?php print CommonLanguage::getMessage('statement_of_income'); ?></div>
            <br>
            <div class="row">
                <div class="input-group  col-md-2 center-margin pull-left">
                    <h5><?php print CommonLanguage::getMessage('enter_nb_digits'); ?></h5>
                    <input type="number" id="digits" min="1" value="20" class="form-control" >



                </div>
                <div class="col-md-3">

                    <h5><?php print CommonLanguage::getMessage('enter_nb_of_grouping'); ?></h5>
                    <input type="number" id="Grouping" min="1" value="2" class="form-control" >
                </div>
                <div class="input-daterange input-group pull-right" id="datepicker-range">
                    <input id="From_To_Date" type="text" class="form-control" name="From_To_Date" >

                </div>
            </div>

            <br>
            <div class="row">

                <div class="col-md-3">
                    <label style="font-size: 18px;"><?php print CommonLanguage::getMessage('collapse'); ?></label>
                    <input type="checkbox" data-init-plugin="switchery" id="ShowTR"/></div>
                <div class="col-md-3 pull-right">
                    <?php echo Forms::CurrencyDropDown(1,'complete')?>

                </div>
            </div>




            <div class="clearfix"></div>
        </div>
        <div class="panel-body">
            <table class="table table-bordered table-hover demo-table-search" id="IncomeStatement">
                <thead>
                    <tr>
                        <th class="text-center" style="width:6%" ><?php print CommonLanguage::getMessage('Code'); ?></th>
                        <th class="text-center" style="width:28%" ><?php print CommonLanguage::getMessage('Name'); ?> </th>
                        <th class="text-center ShowTr HideMe" ><?php print CommonLanguage::getMessage('debit'); ?></th>
                        <th class="text-center ShowTr HideMe" ><?php print CommonLanguage::getMessage('credit'); ?></th>
                        <th class="text-center" style="width:16%"><?php print CommonLanguage::getMessage('Balance'); ?></th>
                        <th class="text-center"  style="width:16%"><?php print CommonLanguage::getMessage('vertical_analysis'); ?></th>
                        <th class="text-center" ><?php print CommonLanguage::getMessage('old_balance'); ?></th>
                        <th class="text-center" ><?php print CommonLanguage::getMessage('old_vertical_analysis'); ?></th>
                        <th class="text-center" ><?php print CommonLanguage::getMessage('horizontal_analysis'); ?></th>
                        <th class="text-center"style="width:16%" ><?php print CommonLanguage::getMessage('horizontal_value'); ?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    for ($x = 0; $x < count($list) - 1; $x++) {
                        $CurItem = $list [$x];

                        for ($j = 0; $j < count($CurItem) - 10; $j++) {
                            $EnterItem = $CurItem[$j];
                            ?>
                            <tr>
                                <td class=' v-align-middle text-center bold'><?php echo $EnterItem["Account_Code"]; ?></td>
                                <td class='v-align-middle text-center bold'><?php echo $EnterItem["Account_Name"]; ?></td>
                                <td class='v-align-middle text-center ShowTr HideMe '><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span><script> document.write(FixNumber(<?php echo $EnterItem["Debit"]; ?>))</script></span></td>
                                <td class='v-align-middle text-center ShowTr HideMe '><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span><script> document.write(FixNumber(<?php echo $EnterItem["Credit"]; ?>))</script></span></td>
                                <td class='v-align-middle text-center '><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span> <?php echo $EnterItem["Balance"][0] == '(' ? "(<script> document.write (FixNumber($EnterItem[Balance]))</script>)" : "<script> document.write (FixNumber($EnterItem[Balance]))</script>"; ?>   </span></td>
                                <td class='v-align-middle text-center '><span >%</span><span> <script> document.write(FixNumber(<?php echo $EnterItem["Vertical_Analysis"]; ?>))</script> </span></td>
                                <td class='v-align-middle text-center '><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span><?php echo $EnterItem["Old_Balance"][0] == '(' ? "(<script> document.write (FixNumber($EnterItem[Old_Balance]))</script>)" : "<script> document.write (FixNumber($EnterItem[Old_Balance]))</script>"; ?> </span></td>
                                <td class='v-align-middle text-center '><span >%</span><span><script> document.write(FixNumber(<?php echo $EnterItem["Vertical_Analysis_Old"]; ?>))</script> </span></td>
                                <td class='v-align-middle text-center '><span >%</span><span><script> document.write(FixNumber(<?php echo $EnterItem["Horizental_Analysis"]; ?>))</script> </span></td>
                                <td class='v-align-middle text-center '><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span><?php echo $EnterItem["Horizental_Value"][0] == '(' ? "(<script> document.write (FixNumber($EnterItem[Horizental_Value]))</script>)" : "<script> document.write (FixNumber($EnterItem[Horizental_Value]))</script>"; ?></span></td>
                            </tr>


    <?php } ?>
                        <tr style="color:#000">
                            <td class=' v-align-middle text-center bold' style="font-size: 1.5em;background-color:#e5e5e5"><?php echo $CurItem["Main_Account_Code"]; ?></td>
                            <td class='v-align-middle text-center bold' style="font-size: 1.5em;background-color:#e5e5e5"><?php echo $CurItem["Main_Account_Name"]; ?></td>
                            <td class='v-align-middle text-center ShowTr HideMe bold' style="font-size: 1.5em;background-color:#e5e5e5"><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span><script> document.write(FixNumber(<?php echo $CurItem["Debit_Per_Account"]; ?>))</script></span></td>
                            <td class='v-align-middle text-center ShowTr HideMe bold' style="font-size: 1.5em;background-color:#e5e5e5"><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span><script> document.write(FixNumber(<?php echo $CurItem["Credit_Per_Account"]; ?>))</script></span></td>
                            <td class='v-align-middle text-center bold' style="font-size: 1.5em;background-color:#e5e5e5"><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span> <?php echo $CurItem["Balance_Per_Account"][0] == '(' ? "(<script> document.write (FixNumber($CurItem[Balance_Per_Account]))</script>)" : "<script> document.write (FixNumber($CurItem[Balance_Per_Account]))</script>"; ?>   </span></td>
                            <td class='v-align-middle text-center bold' style="font-size: 1.5em;background-color:#e5e5e5"><span >%</span><span> <script> document.write(FixNumber(<?php echo $CurItem["Vertical_Analysis_Per_Account"]; ?>))</script> </span></td>
                            <td class='v-align-middle text-center bold' style="font-size: 1.5em;background-color:#e5e5e5"><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span><?php echo $CurItem["Old_Balance_Per_Account"][0] == '(' ? "(<script> document.write (FixNumber($CurItem[Old_Balance_Per_Account]))</script>)" : "<script> document.write (FixNumber($CurItem[Old_Balance_Per_Account]))</script>"; ?> </span></td>
                            <td class='v-align-middle text-center bold' style="font-size: 1.5em;background-color:#e5e5e5"><span >%</span><span><script> document.write(FixNumber(<?php echo $CurItem["Old_Vertical_Analysis_Per_Account"]; ?>))</script> </span></td>
                            <td class='v-align-middle text-center bold' style="font-size: 1.5em;background-color:#e5e5e5"><span >%</span><span><script> document.write(FixNumber(<?php echo $CurItem["Horizental_Analysis_Per_Account"]; ?>))</script> </span></td>
                            <td class='v-align-middle text-center bold' style="font-size: 1.5em;background-color:#e5e5e5"><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span><?php echo $CurItem["Horizental_Value_Per_Account"][0] == '(' ? "(<script> document.write (FixNumber($CurItem[Horizental_Value_Per_Account]))</script>)" : "<script> document.write (FixNumber($CurItem[Horizental_Value_Per_Account]))</script>"; ?></span></td>

                        </tr>


<?php } ?>
                    <tr style="color:#4c0870">

                        <td class=' v-align-middle text-center bold'><?php print CommonLanguage::getMessage('Balance'); ?></td>
                        <td class=' v-align-middle text-center bold'>-</td>
                        <td class=' v-align-middle text-center ShowTr HideMe bold'><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span><script> document.write(FixNumber(<?php echo $list["Final"]["Final_Total_Debit"]; ?>))</script></span></td>
                        <td class='v-align-middle text-center ShowTr HideMe bold'><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span><script> document.write(FixNumber(<?php echo $list["Final"]["Final_Total_Credit"]; ?>))</script></span></td>
                        <td class='v-align-middle text-center bold'><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span><script> document.write(FixNumber(<?php echo $list["Final"]["Final_Balance"] ?>))</script></span></td>
                        <td class='v-align-middle text-center bold'><span >%</span><span><script> document.write(FixNumber(<?php echo $list["Final"]["Final_Vertical_Analysis"]; ?>))</script> </span></td>
                        <td class='v-align-middle text-center bold'><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span><?php echo $list["Final"]["Old_Final_Balance"]; ?></span></td>
                        <td class='v-align-middle text-center bold'><span >%</span><span><script> document.write(FixNumber(<?php echo $list["Final"]["Final_Old_Vertical_Analysis"]; ?>))</script> </span></td>
                        <td class='v-align-middle text-center bold'><span >%</span><span><script> document.write(FixNumber(<?php echo $list["Final"]["Final_Horizental_Analysis"]; ?>))</script> </span></td>
                        <td class='v-align-middle text-center bold'><span class='DefaultCurrency'><?php echo $defCurrencySymbol; ?> </span><span><script> document.write(FixNumber(<?php echo $list["Final"]["Horizental_Value_Balance"]; ?>))</script></span></td>

                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<nav class="navbar navbar-default bg-master-lighter sm-padding-10" role="navigation">
    <div class="container-fluid">
        <div class="collapse navbar-collapse" id="sub-nav">
            <div class="row"> 
                <div class="col-sm-4 ">
                    <ul class="nav navbar-nav navbar-center">
                        <li><a href="#"  title="Print"  data-toggle="modal" class="PrintThisTableButton" data-currency="<?php echo $defCurrencyName ?>" data-table="#IncomeStatement" data-date="<?php echo 'From:' . ($from_day) . ' To: ' . ($today) ?>" data-title="Statement of Income"><i class="fa fa-print"></i></a></li>
                        <li><a href="#" data-toggle="tooltip" data-placement="top" title="Download"><i class="fa fa-download"></i></a></li>
                    </ul>
                </div>
                <div class="col-sm-4 pull-right">
                    <ul class="nav navbar-nav navbar-right">
                        <li>
                            <a href="#" class="p-r-10" data-download-pdf="#IncomeStatement" data-title="Statement of Financial Position"><img width="25" height="25" alt="" class="icon-pdf" data-src-retina="<?php echo SITE_LINK; ?>img/invoice/pdf2x.png" data-src="<?php echo SITE_LINK; ?>img/invoice/pdf2x.png" src="<?php echo SITE_LINK; ?>img/invoice/pdf2x.png"></a>
                        </li>
                        <li>
                            <a href="#" class="p-r-10"><img width="25" height="25" alt="" class="icon-image" data-src-retina="<?php echo SITE_LINK; ?>img/invoice/image2x.png" data-src="<?php echo SITE_LINK; ?>img/invoice/image2x.png" src="<?php echo SITE_LINK; ?>img/invoice/image2x.png"></a>
                        </li>
                        <li>
                            <a href="#" class="p-r-10"><img width="25" height="25" alt="" class="icon-doc" data-src-retina="<?php echo SITE_LINK; ?>img/invoice/doc2x.png" data-src="<?php echo SITE_LINK; ?>img/invoice/doc2x.png" src="<?php echo SITE_LINK; ?>img/invoice/doc2x.png"></a>
                        </li>
                        <li><a href="#" class="p-r-10" onclick="$.Pages.setFullScreen(document.querySelector('html'));return false"><i class="fa fa-expand"></i></a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</nav>
<script>
    var BalanceLang = <?php echo json_encode(CommonLanguage::getMessage('Balance')); ?>;
    var ShowTR = false, fromdate = <?php echo json_encode($from_day) ?>, today = <?php echo json_encode($today) ?>, year =<?php echo json_encode($year1) ?>;



    $(function () {

        var table = $('#IncomeStatement');
        var settings = {
            "sPaginationType": "bootstrap",
            "pagingType": "full_numbers",
            "destroy": true,
            "scrollCollapse": true,
            "aaSorting": [],
           
            "iDisplayLength": 10
        };
        table.dataTable(settings);
     

        CollaspseTr()
        $("input[name=From_To_Date]").daterangepicker({
            locale: {
                format: 'YYYY-MM-DD'
            },
            startDate: fromdate

        }, function (start, end, label) {
            window.startDate = start.format("YYYY-MM-DD"),
                    window.endDate = end.format("YYYY-MM-DD")

        });
        $("#From_To_Date").on("change", function () {

            ChangeTable();
        })
        $("#CurrencyDropDown .dropdown-menu li").click(function () {

            setTimeout(function () {
                ChangeTable();
            }, 1000)
        })
        $("#digits").on("change", function (e) {

            ChangeTable();
        })
        $("#Grouping").on("change", function (e) {

            ChangeTable();
        })


    })
    function ChangeTable() {

        var Date = {
            From_Date: window.startDate ? window.startDate : fromdate,
            To_Date: window.endDate ? window.endDate : today,
            digits: $("#digits").val(),
            Grouping: $("#Grouping").val(),
            Currency_ID: $("#CurrencyDropDown button input").val(),
            actual : 0
        }



        $('#IncomeStatement').DataTable().destroy();
        $("#IncomeStatement tbody").empty();
        $.ajax({
            url: "ACCAjax/IncomeStatementAjax",
            data: Date,
            method: "POST",
            dataType: 'json',
            complete: function (v1, v2) {
                if (v2 == "success") {


                    var All_Data = (v1.responseJSON),
                            Data = All_Data[0],
                            Currency_Symbol = All_Data[1],
                            DataLen = Object.keys(Data).length;


                    for (var i = 0; i < DataLen - 1; i++) {

                        var CurItem = Data[i];
                        var DetLen = Object.keys(CurItem).length;

                        for (var j = 0; j < DetLen - 10; j++) {

                            var TR = "<tr>"
                            TR += "<td class=' v-align-middle text-center bold'>" + Data[i][j]["Account_Code"] + "</td>"
                            TR += "<td class=' v-align-middle text-center'>" + Data[i][j]["Account_Name"] + "</td>"
                            TR += "<td class='v-align-middle text-center ShowTr HideMe'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + FixNumber(Data[i][j]["Debit"]) + "</span></td>"
                            TR += "<td class='v-align-middle text-center ShowTr HideMe'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + FixNumber(Data[i][j]["Credit"]) + "</span></td>"
                            TR += "<td class='v-align-middle text-center'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + (Data[i][j]["Balance"][0] == '(' ? (Data[i][j]["Balance"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data[i][j]["Balance"]))) + "</span></td>"
                            TR += "<td class='v-align-middle text-center'><span>%</span> <span>" + (Data[i][j]["Vertical_Analysis"][0] == '(' ? (Data[i][j]["Vertical_Analysis"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data[i][j]["Vertical_Analysis"]))) + "</span></td>"
                            TR += "<td class='v-align-middle text-center'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + (Data[i][j]["Old_Balance"][0] == '(' ? (Data[i][j]["Old_Balance"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data[i][j]["Old_Balance"]))) + "</span></td>"
                            TR += "<td class='v-align-middle text-center'><span>%</span> <span>" + FixNumber(Data[i][j]["Vertical_Analysis_Old"]) + "</span></td>"
                            TR += "<td class='v-align-middle text-center'><span>%</span> <span>" + FixNumber(Data[i][j]["Horizental_Analysis"]) + "</span></td>"
                            TR += "<td class='v-align-middle text-center'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + (Data[i][j]["Horizental_Value"][0] == '(' ? (Data[i][j]["Horizental_Value"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data[i][j]["Horizental_Value"]))) + "</span></td></tr>"
                            TR = $(TR)
                            $("#IncomeStatement").append(TR)
                        }
                        var NewTR = "<tr style='color:#000'>"
                        NewTR += "<td class=' v-align-middle text-center bold' style='font-size: 1.5em;background-color:#e5e5e5'>" + Data[i]["Main_Account_Code"] + "</td>"
                        NewTR += "<td class=' v-align-middle text-center' style='font-size: 1.5em;background-color:#e5e5e5'>" + Data[i]["Main_Account_Name"] + "</td>"
                        NewTR += "<td class='v-align-middle text-center ShowTr HideMe' style='font-size: 1.5em;background-color:#e5e5e5'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + FixNumber(Data[i]["Debit_Per_Account"]) + "</span></td>"
                        NewTR += "<td class='v-align-middle text-center ShowTr HideMe' style='font-size: 1.5em;background-color:#e5e5e5'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + FixNumber(Data[i]["Credit_Per_Account"]) + "</span></td>"
                        NewTR += "<td class='v-align-middle text-center' style='font-size: 1.5em;background-color:#e5e5e5'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + (Data[i]["Balance_Per_Account"][0] == '(' ? (Data[i]["Balance_Per_Account"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data[i]["Balance_Per_Account"]))) + "</span></td>"
                        NewTR += "<td class='v-align-middle text-center' style='font-size: 1.5em;background-color:#e5e5e5'><span>%</span> <span>" + (Data[i]["Vertical_Analysis_Per_Account"][0] == '(' ? (Data[i]["Vertical_Analysis_Per_Account"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data[i]["Vertical_Analysis_Per_Account"]))) + "</span></td>"
                        NewTR += "<td class='v-align-middle text-center' style='font-size: 1.5em;background-color:#e5e5e5'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + (Data[i]["Old_Balance_Per_Account"][0] == '(' ? (Data[i]["Old_Balance_Per_Account"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data[i]["Old_Balance_Per_Account"]))) + "</span></td>"
                        NewTR += "<td class='v-align-middle text-center' style='font-size: 1.5em;background-color:#e5e5e5'><span>%</span> <span>" + FixNumber(Data[i]["Old_Vertical_Analysis_Per_Account"]) + "</span></td>"
                        NewTR += "<td class='v-align-middle text-center' style='font-size: 1.5em;background-color:#e5e5e5'><span>%</span> <span>" + FixNumber(Data[i]["Horizental_Analysis_Per_Account"]) + "</span></td>"
                        NewTR += "<td class='v-align-middle text-center' style='font-size: 1.5em;background-color:#e5e5e5'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + (Data[i]["Horizental_Value_Per_Account"][0] == '(' ? (Data[i]["Horizental_Value_Per_Account"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data[i]["Horizental_Value_Per_Account"]))) + "</span></td></tr>"
                        NewTR = $(NewTR)
                        $("#IncomeStatement").append(NewTR)








                    }
                    var trFinal = "<tr style='color:#4c0870'> <td class=' v-align-middle text-center bold'>" + BalanceLang + "</td>"
                    trFinal += "<td class=' v-align-middle text-center bold'>-</td>"
                    trFinal += "<td class=' v-align-middle text-center ShowTr HideMe bold'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + FixNumber(Data["Final"]["Final_Total_Debit"]) + "</span></td>"
                    trFinal += "<td class='v-align-middle text-center ShowTr HideMe bold'><span class='DefaultCurrency'> <span>" + FixNumber(Data["Final"]["Final_Total_Credit"]) + "</span></td>"
                    trFinal += "<td class='v-align-middle text-center bold'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + (Data["Final"]["Final_Balance"][0] == '(' ? (Data["Final"]["Final_Balance"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data["Final"]["Final_Balance"]))) + "</span></td>"
                    trFinal += "<td class='v-align-middle text-center bold'><span class='DefaultCurrency'>%</span> <span>" + (Data["Final"]["Final_Vertical_Analysis"][0] == '(' ? (Data["Final"]["Final_Vertical_Analysis"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data["Final"]["Final_Vertical_Analysis"]))) + "</span></td>"
                    trFinal += "<td class='v-align-middle text-center bold'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + (Data["Final"]["Old_Final_Balance"][0] == '(' ? (Data["Final"]["Old_Final_Balance"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data["Final"]["Old_Final_Balance"]))) + "</span></td>"
                    trFinal += "<td class='v-align-middle text-center bold'><span>%</span> <span>" + (Data["Final"]["Final_Old_Vertical_Analysis"][0] == '(' ? (Data["Final"]["Final_Old_Vertical_Analysis"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data["Final"]["Final_Old_Vertical_Analysis"]))) + "</span></td>"
                    trFinal += "<td class='v-align-middle text-center bold'><span>%</span> <span>" + (Data["Final"]["Final_Horizental_Analysis"][0] == '(' ? (Data["Final"]["Final_Horizental_Analysis"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data["Final"]["Final_Horizental_Analysis"]))) + "</span></td>"
                    trFinal += "<td class='v-align-middle text-center bold'><span class='DefaultCurrency'>" + Currency_Symbol + "</span> <span>" + (Data["Final"]["Horizental_Value_Balance"][0] == '(' ? (Data["Final"]["Horizental_Value_Balance"].toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')) : (FixNumber(Data["Final"]["Horizental_Value_Balance"]))) + "</span></td></tr>"
                    trFinal = $(trFinal)
                    $("#IncomeStatement").append(trFinal)
                }
                RebuildTable()
                $(".PrintThisTableButton").attr({"data-currency": $("#CurrencyDropDown > button>span").html(), "data-table": "#IncomeStatement", "data-date": $("#From_To_Date").val()})

            }
        })
    }
    function CollaspseTr() {

        $("#ShowTR").on("change", function () {
            if ($(this).is(":checked")) {
                ShowTR = true;
                $("#IncomeStatement").find('.ShowTr').removeClass("HideMe")

            } else {
                ShowTR = false;
                $("#IncomeStatement").find('.ShowTr').addClass("HideMe")
            }
        })

    }
    function RebuildTable() {
        $('#IncomeStatement').dataTable({
            "sPaginationType": "bootstrap",
            "pagingType": "full_numbers",
            "destroy": true,
            "scrollCollapse": true,
            "aaSorting": [],
           
            "iDisplayLength": 10
        });
        
    }


</script>