
<style>
    .table thead tr >th{

        background-color:#4c0870;
        width:16% !important;
        color:#fff;
    }
    .table thead tr th[class*='sorting_'] {
        color: #fff;
    }
    .bg-master-lighter {
        border:none;
        background-color:#fff;
        border-top:1px solid #ddd;  
    }
    #selected_entry{
        height:90px;
        color: black;
        margin-top:20px;
        font-size: 16px;
        padding-top: 2%;
    }
    .select_table td{
        padding-left: 70px;
    }
</style>

<div class="container-fluid container-fixed-lg bg-white">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div class="panel-title"><?php print CommonLanguage::getMessage('exchange_rate_actual'); ?></div>
            <div id="submitExchange" class="alert alert-success hidden"></div>

            <div class="clearfix"></div>
        </div>
        <div class="panel-body">
            <table class="table table-bordered table-hover demo-table-search" id="tableWithSearch">
                <thead>
                    <tr>
                        <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('account_code'); ?></th>
                        <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('account_name'); ?></th>
                        <th class="text-center" style="width:5%" ><?php print CommonLanguage::getMessage('Type'); ?></th>
                        <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('Balance'); ?></th>

                    </tr>
                </thead>
                <tbody>
                    <?php
                    if (!empty($list)) {

                        for ($x = 0; $x < count($list) - 6; $x++) {
                            $CurItem = $list [$x];
                            ?>
                            <tr>
                                <td class=' v-align-middle text-center bold'><?php echo $CurItem["Account_Code"]; ?></td>
                                <td class=' v-align-middle text-center bold'><?php echo $CurItem["Account_Name"]; ?></td>
                                <td class=' v-align-middle text-center bold'><?php echo $CurItem["Transaction_Type"]; ?></td>
                                <td class=' v-align-middle text-center bold'><?php echo ($list["Local_Currency_Symbol"] . " " . $CurItem["Balance"]); ?></td>
                            </tr>

    <?php } ?>
                        <tr>
                            <td class=' v-align-middle text-center bold'><?php echo $list["Diff_Exchange_Code"]; ?></td>
                            <td class=' v-align-middle text-center bold'><?php echo $list["Diff_Exchange_Name"]; ?></td>
                            <td class=' v-align-middle text-center bold'><?php echo $list["Diff_Exchange_Type"]; ?></td>
                            <td class=' v-align-middle text-center bold'><?php echo ($list["Local_Currency_Symbol"] . " " . $list["Diff_Exchange_Balance"]); ?></td>
                        </tr>
<?php } ?>
                </tbody>
            </table>

            <div class="container-sm-height">
                <button class=" btn  btn-cons m-b-10 pull-right" id="SubmitButton" style="color:#fff;background-color:#4c0870 ;padding-top: 10px;top: 20px;min-width:253px;" type="button" <?php echo count($list) > 0 ? '' : 'disabled' ?>><i class="pg-form"></i> <span class="bold">Submit</span></button>
            </div>

        </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="#" data-toggle="tooltip" data-placement="bottom" title="Print" class="PrintThisTableButton" data-table="#tableWithSearch" data-date="<?php echo $today ?>" data-title="Exchange Rate List Actual"><i class="fa fa-print"></i></a></li>
                        <li><a href="#" data-toggle="tooltip" data-placement="bottom" 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="#tableWithSearch" data-title="Exchange Rate List Actual"><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 Failed_Submit = <?php echo json_encode(CommonLanguage::getMessage('Failed_Submit')); ?>,
            Submitted_Successfully = <?php echo json_encode(CommonLanguage::getMessage('Submitted_Successfully')); ?>,
            title =<?php print json_encode(CommonLanguage::getMessage('exchange_rate_actual')); ?>;
    var data_array = <?php echo json_encode($list) ?>;
    $(function () {
        $("#SubmitButton").on("click", function () {
//        $("#tableWithSearch tbody tr").each(function(e){
            var me = $(this);
            var Data = {
                Records: data_array,
                Submit_Close: 1,
                actual: 1
            };
            $.ajax({
                url: "ACCAjax/currencyExchangeRateAjax",
                method: "POST",
                data: Data,
                complete: function (v1, v2) {
                    if (v2 == "success" && v1.responseText == 'OK') {
                        $("#submitExchange").attr("class", "alert alert-success").html(Submitted_Successfully)
                    } else {
                        $("#submitExchange").attr("class", "alert alert-danger").html(v1.responseText/*Failed_Submit*/)
                    }
                    $(document.body).animate({scrollTop: 0}, 800)
                }
            })
            //})
        })
        $('#tableWithSearch').dataTable({
            "processing": false,
            "serverSide": false,
            "aLengthMenu": [[10, 25, 50, 100, 500, 800], [10, 25, 50, 100, 500, 800]],
            "bSort": true,
            dom: 'Blfrtip',
            "pagingType": "full_numbers",
            "aaSorting": [],
            "columnDefs": [
                {"className": "dt-center", "targets": "_all"}
            ],
            buttons: [
                {
                    extend: 'excelHtml5',
                    exportOptions: {"columns": [0., 1, 2, 3]},
                    title: title,
                    text: '<i class="fa fa-file-excel-o"></i> Excel'

                },
                {
                    extend: 'print',
                    text: '<i class="fa fa-print"></i> Print',
                    exportOptions: {"columns": [0., 1, 2, 3]},
                    title: title
                },
                {
                    extend: 'csv',
                    text: '<i class="fa fa-file-excel-o"></i> CSV',
                    exportOptions: {"columns": [0., 1, 2, 3]},
                    title: title

                }
            ],
            "pageLength": 50
        });
    })
</script>
