
<style>
    .MonthPicker,.YearPicker,.FromToPicker{
        display:none;
    }
    .table thead tr >th{
        background-color:#ed9421;
        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;  
    }

    .btn-default{
        border: none;
    }
    .btn-default:hover{
        background-color:#ed9421!important;
        color:#fff;
        border: none;
    }
    .complete ,.btn-group  .active{
        background-color:#ed9421!important;
        color:#fff;
    }
        .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;
    }

</style>
<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('weighbridge_list'); ?></div>
            <div id="ViewMode">
                <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'); ?>
                    </label>
                </div>
            </div>
            <div class="col-md-12 DatePicker ">
                <div class="form-group form-group-default input-group col-md-3 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-success-darker"><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-3 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-success-darker"><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-3 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-success-darker"><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-5 pull-right" >

                    <input id="From-range"type="text" class="form-control" name="start" value="<?php echo $today ?>">
                    <span class="input-group-addon bg-success-darker"><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 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:10%"><?php print CommonLanguage::getMessage('registration'); ?> #</th>
                        <th class="text-center" style="width:5%" ><?php print CommonLanguage::getMessage('amount'); ?></th>
                        <th class="text-center" style="width:5%" ><?php print CommonLanguage::getMessage('Status'); ?></th>
                        <th class="text-center no-print" style="width:5%" ><?php print CommonLanguage::getMessage('option'); ?></th>
                    </tr>
                </thead>
                <tbody>

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

<script>
    var title = <?php echo json_encode(CommonLanguage::getMessage('weighbridge_list')) ?>;
    $("#tableWithSearch ").on("click", ".Paid_Status>li", function (e) {
        e.preventDefault();
        var Data = {
            Is_Paid: $(this).attr("value"),
            Weighbridge_ID: $(this).parent().attr("data-id"),
            Weighbridge_Vehicle_ID: $(this).parents("tr").find('span.label').attr("data-code"),
            Weighbridge_Vehicle_Number: $(this).parents("tr").find("td:eq(0)").text(),
            Weighbridge_Date: <?php echo json_encode($today) ?>,
            Weighbridge_Amount: $(this).parents("tr").find('span.label').attr("data-amount"),
            Weighbridge_Currency_ID: $(this).parents("tr").find('span.label').attr("data-currency")
        };
        $.ajax({
            url: "GarageAjax/WeighbridgeListAjax",
            data: Data,
            complete: function (v1, v2) {
                if (v2 == "success" && v1.responseText == "OK") {
                    ChangeTable();
                }
            }

        });
    });
    $(function () {
        ChangeTable();

        $("body").addClass("NoSearch")
        $("body .search-link[data-toggle='search']").html("<i class='pg-search'></i>Click here to <span class='bold'>search</span>")
        $("#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();
        })
        $("#From-range,#To-range").datepicker({autoclose: true}).on("changeDate", function (e) {
            ChangeTable();
        })
    })
    function ChangeTable() {
        var CheckedValue = parseInt($("#ViewMode input:checked").val());
        var CurrentData = {};
        if (CheckedValue == 4) {
            CurrentData.WeighBridge_Date_From = $("#From-range").val();
            CurrentData.WeighBridge_Date_To = $("#To-range").val();
            CurrentData.CheckedValue = CheckedValue;
        } else {
            CurrentDate(CheckedValue)
            CurrentData.WeighBridge_Date = FinalDate;
            CurrentData.CheckedValue = CheckedValue;


        }
        RebuildDataTable(title, [0, 1, 2], "GarageAjax/WeighBrigeListRequest", CurrentData)

    }


    function switchcase() {
        var CheckedValue = parseInt($("#ViewMode input:checked").val());
        switch (CheckedValue) {
            case 1:
                $(".DatePicker").show();
                $(".MonthPicker,.YearPicker,.FromToPicker").hide();
                break;
            case 2:
                $(".DatePicker,.YearPicker,.FromToPicker").hide();
                $(".MonthPicker").show();
                break;
            case 3:
                $(".DatePicker,.MonthPicker,.FromToPicker").hide();
                $(".YearPicker").show();
                $("#Year_Date").datepicker({autoclose: true, viewMode: "years", minViewMode: "years", })
                break;

            case 4:
                $(".DatePicker,.MonthPicker,.YearPicker").hide();
                $(".FromToPicker").show();
                $("#From-range").datepicker({autoclose: true})
                $("#To-range").datepicker({autoclose: true})
                break;
        }
    }
</script>
