// function getDate() {
//     const selectedDos = document.getElementById("dos").value;
//     if (selectedDos.length > 0) {
//         console.log(selectedDos);
//         if (moment(selectedDos).isBetween('12/31/1999', '01/01/2019')) {
//             document.getElementById("localityDiv").style.display = 'none';
//             document.getElementById("countyListDiv").style.display = 'none';
//         }
//         else {
//             document.getElementById("localityDiv").style.display = 'block';
//             document.getElementById("countyListDiv").style.display = 'block';
//         }

//         if (moment(selectedDos).isBetween('12/31/1999', '03/01/2017')) {

//             document.getElementById("conversionfactor").options[0].style.display = 'block';
//             document.getElementById("conversionfactor").options[1].style.display = 'block';
//             document.getElementById("conversionfactor").options[2].style.display = 'block';
//             document.getElementById("conversionfactor").options[3].style.display = 'block';
//         }
//         else {
//             document.getElementById("conversionfactor").options[0].style.display = 'none';
//             document.getElementById("conversionfactor").options[2].style.display = 'none';
//             document.getElementById("conversionfactor").options[1].style.display = 'block';
//             document.getElementById("conversionfactor").options[3].style.display = 'block';
//             //document.getElementById("conversionfactor").value = 'Other Services';
//         }

//     }


// }


$(function () {

    /* disable click events outsite from modal */
    $('.modal').modal({
        backdrop: 'static',
        keyboard: false
    });


    // onload call select2 locality county list
    $(".js-example-basic-single").select2({
        width: '100%'
    });

    //selectRefresh();

    /*Units Pattern*/
    $('.units').on('input', function (e) {
        $(this).val($(this).val().replace(/[^0-9]/g, ''));

        if($(this).val() < 1){
            $(this).addClass('invalid-unit');

        }else{
            $(this).removeClass('invalid-unit');

        }
    });
    $('.cptcode').mask('AAAAA');

    /*Date Picker Pattern*/
    $('#dos').datepicker({
        format: 'mm/dd/yyyy',
        language: "es",
        autoclose: true,
        startDate: "01/01/2000"
    });
    $('#dos').mask('00/00/0000');

    $('#e-dos').datepicker({
        format: 'mm/dd/yyyy',
        language: "es",
        autoclose: true,
        startDate: "01/01/2000"
    });
    $('#e-dos').mask('00/00/0000');

    $('#rfa-dos').datepicker({
        format: 'mm/dd/yyyy',
        language: "es",
        autoclose: true,
        startDate: "01/01/2000"
    });
    $('#rfa-dos').mask('00/00/0000');

    $('#pr2-dos').datepicker({
        format: 'mm/dd/yyyy',
        language: "es",
        autoclose: true,
        startDate: "01/01/2000"
    });
    $('#pr2-dos').mask('00/00/0000');

    $('#admin-dos').datepicker({
        format: 'mm/dd/yyyy',
        language: "es",
        autoclose: true,
        startDate: "01/01/2000"
    });
    $('#admin-dos').mask('00/00/0000');

    /*Payment Total Pattern*/
    // $('.charges').mask("###.##", { reverse: false });

    /*Date Comparison*/
    // $(".dos_input").on("change", function () {
    //     var sb_dos_selected = $(this).val();

    //     if (moment(sb_dos_selected).isBetween('12/31/1999', '04/15/2014'))	// 01/01/2014 to 04/14/2014 for ID=1
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();
    //         $(".convFactorDiv select option[value='Radiology Services']").show();
    //         $(".convFactorDiv select option[value='Surgery']").show();

    //     }
    //     else if (moment(sb_dos_selected).isBetween('04/14/2014', '07/01/2014'))  // 04/15/2014 to 06/30/2014 for ID=2
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();
    //         $(".convFactorDiv select option[value='Radiology Services']").show();
    //         $(".convFactorDiv select option[value='Surgery']").show();

    //     }
    //     else if (moment(sb_dos_selected).isBetween('06/30/2014', '10/01/2014'))	// 07/01/2014 to 09/30/2014 for ID=3
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();
    //         $(".convFactorDiv select option[value='Radiology Services']").show();
    //         $(".convFactorDiv select option[value='Surgery']").show();

    //     }
    //     else if (moment(sb_dos_selected).isBetween('09/30/2014', '03/01/2015'))	// 10/01/2014 to 02/28/2015 for id = 4
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();
    //         $(".convFactorDiv select option[value='Radiology Services']").show();
    //         $(".convFactorDiv select option[value='Surgery']").show();

    //     }
    //     else if (moment(sb_dos_selected).isBetween('02/28/2015', '05/01/2015'))	// 03/01/2015 to 04/30/2015 for id = 5
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();
    //         $(".convFactorDiv select option[value='Radiology Services']").show();
    //         $(".convFactorDiv select option[value='Surgery']").show();

    //     }
    //     else if (moment(sb_dos_selected).isBetween('04/30/2015', '07/01/2015'))	// 05/01/2015 to 06/30/2015 for id = 6
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();
    //         $(".convFactorDiv select option[value='Radiology Services']").show();
    //         $(".convFactorDiv select option[value='Surgery']").show();

    //     }
    //     else if (moment(sb_dos_selected).isBetween('06/30/2015', '10/01/2015'))	// 07/01/2015 to 09/30/2015 for id=7
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();
    //         $(".convFactorDiv select option[value='Radiology Services']").show();
    //         $(".convFactorDiv select option[value='Surgery']").show();

    //     }
    //     else if (moment(sb_dos_selected).isBetween('09/30/2015', '01/01/2016'))	// 10/01/2015 to 12/31/2015 for id=8
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();
    //         $(".convFactorDiv select option[value='Radiology Services']").show();
    //         $(".convFactorDiv select option[value='Surgery']").show();

    //     }
    //     else if (moment(sb_dos_selected).isBetween('12/31/2015', '04/01/2016'))	// 01/01/2016 to 03/31/2016 for id=9
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();
    //         $(".convFactorDiv select option[value='Radiology Services']").show();
    //         $(".convFactorDiv select option[value='Surgery']").show();

    //     }
    //     else if (moment(sb_dos_selected).isBetween('03/31/2016', '07/01/2016'))	// 04/01/2016 to 06/30/2016 for id=10
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();
    //         $(".convFactorDiv select option[value='Radiology Services']").show();
    //         $(".convFactorDiv select option[value='Surgery']").show();

    //     }
    //     else if (moment(sb_dos_selected).isBetween('06/30/2016', '10/01/2016'))	// 07/01/2016 to 09/30/2016 for id=11
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();
    //         $(".convFactorDiv select option[value='Radiology Services']").show();
    //         $(".convFactorDiv select option[value='Surgery']").show();

    //     }
    //     else if (moment(sb_dos_selected).isBetween('09/30/2016', '03/01/2017'))	// 10/01/2016 to 02/28/2017 for id=12
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();

    //         $(".convFactorDiv select option[value='Radiology Services']").show();
    //         $(".convFactorDiv select option[value='Surgery']").show();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('02/28/2017', '04/01/2017'))	// 03/01/2017 to 03/31/2017 for id=13
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('03/31/2017', '07/01/2017'))	// 04/01/2017 to 06/30/2017 for id=14
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('06/30/2017', '10/01/2017'))	// 07/01/2017 to 09/30/2017 for id=15
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('09/30/2017', '01/01/2018'))	// 10/01/2017 to 12/31/2017 for id=16
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('12/31/2017', '04/01/2018'))	// 01/01/2018 to 03/31/2018 for id=17
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('03/31/2018', '07/01/2018'))	// 04/01/2018 to 06/30/2018 for id=18
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('06/30/2018', '10/01/2018'))	// 07/01/2018 to 09/30/2018 for id=19
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('09/30/2018', '01/01/2019'))	// 10/01/2018 to 12/31/2018 for id=20
    //     {
    //         $(".localityDiv").hide();
    //         $(".countyListDiv").hide();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     //await localityList.run();
    //     else if (moment(sb_dos_selected).isBetween('12/31/2018', '04/01/2019'))	// 01/01/2019 to 03/31/2019 for id=21
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('03/31/2019', '07/01/2019'))	// 04/01/2019 to 06/30/2019 for id=22
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();

    //     }
    //     else if (moment(sb_dos_selected).isBetween('06/30/2019', '10/01/2019'))	// 07/01/2019 to 09/30/2019 for id=23
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('09/30/2019', '01/01/2020'))	// 10/01/2019 to 12/31/2019 for id=24
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('12/31/2019', '03/01/2020'))	// 01/01/2020 to 02/29/2020 for id=25
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('02/29/2020', '04/01/2020'))	// 03/01/2020 to 03/31/2020 for id=26
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('03/31/2020', '07/01/2020'))	// 04/01/2020 to 06/30/2020 for id=27
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('06/30/2020', '10/01/2020'))	// 07/01/2020 to 09/30/2020 for id=28
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('09/30/2020', '03/01/2021'))	// 10/01/2020 to 02/28/2021 for id=29
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('02/28/2021', '04/01/2021'))	// 03/01/2021 to 03/31/2021 for id=30
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('03/31/2021', '07/01/2021'))	// 04/01/2021 to 06/30/2021 for id=31
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('06/30/2021', '10/01/2021'))	// 07/01/2021 to 09/30/2021 for id=32
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('09/30/2021', '01/01/2022'))	// 10/01/2021 to 12/31/2021 for id=33
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('12/31/2021', '04/01/2022'))	// 01/01/2022 to 03/31/2022 for ID=34
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isBetween('03/31/2022', '07/01/2022'))	// 04/01/2022 to 06/30/2022 for ID=35
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();

    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }
    //     else if (moment(sb_dos_selected).isAfter(moment('06/30/2022', 'MM/DD/YYYY')))  // 07/01/2022 to Onward
    //     {
    //         $(".localityDiv").show();
    //         $(".countyListDiv").show();
    //         $(".convFactorDiv select option[value='Radiology Services']").hide();
    //         $(".convFactorDiv select option[value='Surgery']").hide();
    //     }


    // });

    var formSubmitted = false;
    /*Check Physician Form Validation before Submit*/
    $("#submitButton").click(function (event) {
        //Fetch form to apply custom Bootstrap validation
        var form = $("#calc_form")
        if (form[0].checkValidity() !== false) {
            //Check cptcodes in multiple rows
            $(".cptcode").each(function () {
                if (!$(this).val()) {
                    $(this).parent().parent().parent().remove();
                }
            });

            formSubmitted = true;
            $('.modal').modal('show');
        }
        else if (form[0].checkValidity() === false) {
            event.preventDefault()
            event.stopPropagation()
        }
        form.addClass('was-validated')

    });

    $("#e-submitButton").click(function (event) {
        //Fetch form to apply custom Bootstrap validation
        var form = $("#e-calc_form")
        if (form[0].checkValidity() !== false) {
            //Check cptcodes in multiple rows
            $(".cptcode").each(function () {
                if (!$(this).val()) {
                    $(this).parent().parent().parent().remove();
                }
            });

            formSubmitted = true;
            $('.modal').modal('show');
        }
        else if (form[0].checkValidity() === false) {
            event.preventDefault()
            event.stopPropagation()
        }
        form.addClass('was-validated')

    });

    $("#rfa-submitButton").click(function (event) {
        //Fetch form to apply custom Bootstrap validation
        var form = $("#rfa-calc_form")
        if (form[0].checkValidity() !== false) {
            //Check cptcodes in multiple rows
            $(".cptcode").each(function () {
                if (!$(this).val()) {
                    $(this).parent().parent().parent().remove();
                }
            });

            formSubmitted = true;
            $('.modal').modal('show');
        }
        else if (form[0].checkValidity() === false) {
            event.preventDefault()
            event.stopPropagation()
        }
        form.addClass('was-validated')

    });

    $("#pr2-submitButton").click(function (event) {
        //Fetch form to apply custom Bootstrap validation
        var form = $("#pr2-calc_form")
        if (form[0].checkValidity() !== false) {
            //Check cptcodes in multiple rows
            $(".cptcode").each(function () {
                if (!$(this).val()) {
                    $(this).parent().parent().parent().remove();
                }
            });

            formSubmitted = true;
            $('.modal').modal('show');
        }
        else if (form[0].checkValidity() === false) {
            event.preventDefault()
            event.stopPropagation()
        }
        form.addClass('was-validated')

    });

    $("#admin-submitButton").click(function (event) {
        //Fetch form to apply custom Bootstrap validation
        var form = $("#admin-calc_form")
        if (form[0].checkValidity() !== false) {
            //Check cptcodes in multiple rows
            $(".cptcode").each(function () {
                if (!$(this).val()) {
                    $(this).parent().parent().parent().remove();
                }
            });

            formSubmitted = true;
            $('.modal').modal('show');
        }
        else if (form[0].checkValidity() === false) {
            event.preventDefault()
            event.stopPropagation()
        }
        form.addClass('was-validated')

    });

    if (!formSubmitted) {
        $('.modal').modal('hide');
    }



    /*BS4 Table Data*/
    var $table = $('#table');
    $(function () {
        $('#toolbar').find('select').change(function () {
            $table.bootstrapTable('refreshOptions', {
                exportDataType: $(this).val(),
                'data-pagination': 'true',

            });
        });
    })

    var trBoldBlue = $("table");

    $(trBoldBlue).on("click", "tr", function () {
        $(this).toggleClass("bold-blue");
    });


    $('#csvTable').bootstrapTable({
        'data-pagination': true
    });


});

$(document).ready(function () {
    /*Alert Messages for 3 seconds*/
    setTimeout(function () {
        $('.alert').hide("slow");
    }, 4000);

    var email, serviceName, cptcode, omfs;
    $('#table tbody').on('click', 'tr', function () {
        // var rowData = $(this).children('td').map(function(){
        //     return $(this).text();
        // }).get();
        email = $(this).find('td:first-child').text();
        serviceName = $(this).find('td:nth-of-type(2)').text();
        cptcode = $(this).find('td:nth-of-type(9)').text();
        omfs = $(this).find('td:last-child').text();

        $('.email').html(email);
        $('.serviceName').html(serviceName);
        $('.cptcode').html(cptcode);
        $('.omfs').html(omfs);

        // for (var i = 0; i < rowData.length; i++) {
        // $('.row-details').append('<div class="col-md-4">'+rowData[i]+'</div>');
        // }
    });

});
