
<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;  
    }
    .datepicker thead tr .dow {
        color:#4c0870  !important;
    }
    .datepicker table tr td.day:hover {
        background: #4c0870  !important;
        color:#fff;
    }
    .datepicker table tr td.active {
        background-color: #4c0870  !important;
    }
    .datepicker thead tr .datepicker-switch {
        color: #4c0870   !important;
        font-size: 13px;
    }
    .datepicker table tr td span.active {
        background-color: #4c0870  !important;
    }
    .datepicker table tr td span:hover {
        background-color: #4c0870  !important;
        color:#fff;
    }
    datepicker thead tr .next:before, .datepicker thead tr .prev:before {
        color: #4c0870  !important;
        font-family: 'FontAwesome';
        font-size: 10px;
    }
    .datepicker thead tr .next:before, .datepicker thead tr .prev:before {
        color: #4c0870  !important;
        font-family: 'FontAwesome';
        font-size: 10px;
    }
    .btn-default:hover{
        background-color:#ed9421 !important;
        color:#fff;
        border: none;
    }
    .complete ,.btn-group  .active{
        background-color:#ed9421 !important;
        color:#fff;
    }
    .MonthPicker,.YearPicker,.FromToPicker{
        display:none;
    }
    #selected_entry{
        height:90px;
        color: black;
        margin-top:20px;
        font-size: 16px;
        padding-top: 2%;
    }
    .select_table td{
        padding-left: 70px;
    }
    
    .applyBtn{
        background-color: #ed9421 !important;
        }
</style>
<script src="<?php echo JS_PATH;?>scripts.js"></script>
<script src="<?php echo THEME_PATH; ?>/plugins/moment/moment.min.js"></script>

<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_list');?></div>
            <div class="col-md-12">
            <div id="ViewMode" class="col-md-4">
                <span style="margin:0 13px"><?php print CommonLanguage::getMessage('type');?>: </span>
                <div class="btn-group" data-toggle="buttons">
                    <label class="btn btn-default active">
                        <input type="radio" name="ViewType" value="1" checked=""><?php print CommonLanguage::getMessage('Daily');?>
                    </label>
                    <label class="btn btn-default">
                        <input type="radio" name="ViewType" value="2"><?php print CommonLanguage::getMessage('monthly');?>
                    </label>
                    <label class="btn btn-default">
                        <input type="radio" name="ViewType" value="3"><?php print CommonLanguage::getMessage('yearly');?>
                    </label>
                    <label class="btn btn-default">
                        <input type="radio" name="ViewType" value="4"><?php print CommonLanguage::getMessage('from_to');?>
                </div>
            </div>
                <div class="col-md-6 pull-right">
            <div class="col-md-12 DatePicker ">
                <div class="form-group form-group-default input-group col-md-5 pull-right" >
                    <label class="fade"><?php print CommonLanguage::getMessage('Date');?></label>
                    <input type="text" id="Daily_Date" name="Daily_Date" class="form-control" data-date-format="yyyy-mm-dd" value="<?php echo($today); ?>" aria-required="true" aria-invalid="false">
                    <span class="input-group-addon bg-complete"><i class="fa fa-calendar"></i></span>
                </div>
                
               
                
            </div>
            <div class="col-md-12 MonthPicker ">
                <div class="form-group form-group-default input-group col-md-5 pull-right" >
                    <label class="fade"><?php print CommonLanguage::getMessage('month');?></label>
                    <input type="text" id="Month_Date" name="Month_Date" class="form-control" data-date-format="yyyy-mm" value="<?php echo($year).'-'.($monthName); ?>" aria-required="true" aria-invalid="false">
                    <span class="input-group-addon bg-complete"><i class="fa fa-calendar"></i></span>
                </div> 
                
            </div>
            <div class="col-md-12 YearPicker ">
                <div class="form-group form-group-default input-group col-md-5 pull-right" >
                    <label class="fade"><?php print CommonLanguage::getMessage('year');?></label>
                    <input type="text" id="Year_Date" name="Year_Date" class="form-control" data-date-format="yyyy" value="<?php echo($year); ?>" aria-required="true" aria-invalid="false">
                    <span class="input-group-addon bg-complete"><i class="fa fa-calendar"></i></span>
                </div> 
                
            </div>
            <div class="col-md-12 FromToPicker ">
                <div class="form-group form-group-default input-group col-md-6" >
                    <input id="From_To_Date" type="text" class="form-control" name="From_To_Date" >
<!--
                    <input id="From-range"type="text" class="form-control" name="start" value="<//?php echo $today?>">
                    <span class="input-group-addon bg-complete"><i class="fa fa-calendar"></i></span>
                    <input id="To-range"type="text" class="form-control" name="end" value="<//?php echo $today?>">
-->
                </div> 
                
            </div>
            </div>
        </div>
            <div class="clearfix"></div>
        </div>
        <div  class="form-group BootstrapDropDown col-md-12">
             <div class="form-group BootstrapDropDown col-md-2">
                    <label><?php print CommonLanguage::getMessage('from_currency');?></label>
                    <select id="From_Currency" class="full-width AccountCode" data-init-plugin="select2" >
                        <?php foreach ($currency_codes as $codes):?>
                        <option code="<?php echo $codes['Currency_Code']; ?>"  value="<?php echo $codes['Currency_ID']; ?>"><?php echo $codes['Currency']; ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            <div class="form-group BootstrapDropDown col-md-2">
                    <label><?php print CommonLanguage::getMessage('to_currency');?></label>
                    <select id="To_Currency"  class="full-width AccountCode" data-init-plugin="select2" >
                        <?php foreach ($currency_codes as $codes):?>
                        <option code="<?php echo $codes['Currency_Code']; ?>" value="<?php echo $codes['Currency_ID']; ?>"><?php echo $codes['Currency']; ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
        </div>
        <div class="panel-body">
            
            <table class="table table-bordered table-hover demo-table-search" id="tableWithSearch">
                <thead>
                    <tr>
                        <th class="text-center" ><?php print CommonLanguage::getMessage('rate');?></th>
                        <th class="text-center" ><?php print CommonLanguage::getMessage('Date');?> </th>
                    </tr>
                </thead>
                <tbody>
                    
                </tbody>
            </table>
        </div>
    </div>
</div>
<script>
    var CodeFrom , CodeTo, startDate, endDate,title = <?php print json_encode(CommonLanguage::getMessage('exchange_rate_list'));?>;
    var today = <?php echo json_encode($today)?>;
    $(function(){
           $("input[name=From_To_Date]").daterangepicker({
        },     function(start, end,label){
            window.startDate = start.format("YYYY-MM-DD"),
                window.endDate = end.format("YYYY-MM-DD")
            
            ChangeTable();
 
        });
        $("button").tooltip();
        $('#tableWithSearch').dataTable();
        $('#search-table').on("keyup",function() {
            $('#tableWithSearch').dataTable().fnFilter($(this).val());
        });
        $("#ViewMode label.btn").on("change",function(){
            setTimeout('switchcase()',100)
            ChangeTable();
        })
        $("#Daily_Date").datepicker({autoclose:true }).on("changeDate",function(e){
            ChangeTable();
	  
        })
        $("#Month_Date").datepicker({autoclose:true, viewMode:"months",minViewMode:"months",}).on("changeDate",function(e){
            
            ChangeTable();
	})
        $("#Year_Date").datepicker({autoclose:true, viewMode:"years",minViewMode:"years",}).on("changeDate",function(e){
            
            ChangeTable();
	})
     
        
       
    })
    function ChangeTable(){
        var CheckedValue =  parseInt($("#ViewMode input:checked").val());
        var Date={
            From_Currency : $("#From_Currency").val(),
            To_Currency   : $("#To_Currency").val()
        };
        if(CheckedValue == 4){
    
                Date.Exchange_List_Date_From =  window.startDate ? window.startDate : today
                Date.Exchange_List_Date_To =  window.endDate ? window.endDate : today
                Date.CheckedValue =  parseInt($("#ViewMode input:checked").val())
          
        }
        else {
            CurrentDate(CheckedValue)
            
            Date.Exchange_List_Date =FinalDate
            Date.CheckedValue =  parseInt($("#ViewMode input:checked").val())
           
        }
            
        
        
        RebuildDataTable(title,[0,1],"ACCAjax/ExchangeRateListRequest",Date);
        
    }

    function switchcase(){ 
        var CheckedValue =  parseInt($("#ViewMode input:checked").val());
               
               
        switch(CheckedValue){
            case 1:
                $(".DatePicker").show();
                $(".MonthPicker").hide();
                $(".YearPicker").hide();
                $(".FromToPicker").hide();
                break;
            case 2:
                $(".DatePicker").hide();
                $(".MonthPicker").show();
                $(".YearPicker").hide();
                $(".FromToPicker").hide();
                break;
            case 3:
                $(".DatePicker").hide();
                $(".MonthPicker").hide();
                $(".YearPicker").show();
                $(".FromToPicker").hide();
                break;
            case 4:
                $(".DatePicker").hide();
                $(".MonthPicker").hide();
                $(".YearPicker").hide();
                $(".FromToPicker").show();
                $("#From-range").datepicker({autoclose:true})
                $("#To-range").datepicker({autoclose:true})
              break;
        }
    }

</script>