$(document).ready(function () {
    //GetReminderConfiguration();
    //add dynamic form starts
    //var template = $('#psections .section:first').clone();

    
    //var sectionsCount = 1;
    
    //$('body').on('click', '.addPsection', function () {

        
    //    sectionsCount++;
    //    if (sectionsCount < 4) {
            
    //        var section = template.clone().find(':input').each(function () {

                
    //            var newId = this.id + sectionsCount;

                
    //            $(this).prev().attr('for', newId);

                
    //            this.id = newId;

    //        }).end()

                
    //            .appendTo('#psections');
    //        return false;
    //    } else {
    //        $('.addPsection').hide();
    //    }
    //});
    //$('#psections').on('click', '.removePsection', function () {
        
    //    $(this).parent().fadeOut(300, function () {
            
    //        $(this).parent().empty();
    //        if ($('#psections').length < 3) {
    //            $('.addPsection').show();
    //        }
    //        return false;
    //    });
    //    return false;
    //});

});
function GetReminderConfiguration() {
    var ReminderConfiguration = {
        Dml_Indicator: 'S'
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/RemainderConfiguration/ReminderConfiguration',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(ReminderConfiguration),
        success: function (data) {
            var value;
            var value1 = '<br>keep encouraging the better performers for completing their daily goals via messages saying <br>"Good! You have completed your daliy fitness target,keep up the pace!"';
            var value2 = '<br>Motivate the patients to follow their needed activities with daliy reminder saying<br> "You have fallen short of your fitness target today! Make time for walking everyday"';
            var value3 = '<br>supporting the patients for accomplishing their weekly fitness goals<br> "Great! You have completed your weekly fitness target,kudos to repeat the same performance next week"';
            var value4 = '<br>sends weekly reminder to your patients to enhance their health progress<br> "Missed your weekly fitness target? No worries,stay focussed the taget next week"';
            


            var urcheck = $('#URight').val();
            if (urcheck == "1") {
                var Reminder = '<div class=\"table-responsive\"><table id=\"remainderConfig\" class=\"ur-remainder-conf-table table-responsive table table-condensed body-borderless table_borderless dataTable no-footer\" cellspacing=\"0\" width=\"100%\"><thead><tr><th>S No</th><th>Reminder</th><th>Action</th></tr></thead><tbody>';
            }
            if (urcheck == "2") {
                var Reminder = '<div class=\"table-responsive\"><table id=\"remainderConfig\" class=\"ur-remainder-conf-table table-responsive table table-condensed body-borderless table_borderless dataTable no-footer\" cellspacing=\"0\" width=\"100%\"><thead><tr><th>S No</th><th>Reminder</th></tr></thead><tbody>';
            }
            $.each(data, function (i, emp) {
                if (i==0) {
                    value=value1
                }
                if (i==1) {
                    value=value2
                }
                if (i == 2) {
                    value = value3
                }
                if (i == 3) {
                    value = value4
                }
                Reminder = Reminder + '<tr><td>' + (i + 1) + '</td><td>' + emp.ReminderConfiguration_name + "</br> " +value+'</td>';
                if (urcheck == "1") {
                    Reminder = Reminder + ' <td><div class="onoffswitch"><input type="checkbox" name="onoffswitch" onchange="StatusChange(this,' + '\'' + emp.ReminderConfiguration_id + '\',\'' + emp.ReminderConfiguration_id + '\');" class="onoffswitch-checkbox" id="myonoffswitch' + (i + 1) + '"';
                    if (emp.Reminder_Configuration_status == '1') {
                        Reminder = Reminder + 'checked';
                    }
                    Reminder = Reminder + '><label class="onoffswitch-label" for="myonoffswitch' + (i + 1) + '"><span class="onoffswitch-inner"></span><span class="onoffswitch-switch"></span></label></div></td>';
                }
            });

            Reminder = Reminder + '</tbody></table></div>';
            $('#tblReminder').html(Reminder);



        }
    });
}
function StatusChange(obj, Doctor_Id, Patient_ID) {
    var Configuration = {
        ReminderConfiguration_id: Doctor_Id,
        Reminder_Configuration_status: obj.checked,
        Dml_Indicator: 'U'
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/RemainderConfiguration/UpdateReminderConfiguration',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(Configuration),
        success: function (data1) {
            alert(data1);
        }
    });
}
