/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 * Amr in 16-11-2015
 */
var host_url = $('#hosturl').val();

$(document).ready(function () {

    $("#awval").validate();
    $(".awval").validate();
    $(".today").datepicker("setDate", "0");
    $(".tomoro").datepicker("setDate", "+1");
    $(".datepicker").datepicker();
    $.datepicker.setDefaults({
        dateFormat: "yy/mm/dd",
        changeMonth: true,
        changeYear: true
    });
    $(".datepicker").datepicker({
        appendText: "(yy/mm/dd)"
    });

    $('[data-toggle="popover"]').popover();

    var minxhit = $(window).height();
    var mihitx = minxhit + "px";
    $("#pageminheight").css("min-height", mihitx);
/////////////////////////

//$(window).scroll(function () {
//    if ($(this).scrollTop() > 370) {
//        $('.opsrisk').addClass('fixed');
//        var fulwdz = $('.col-md-12').width();
//        var fullwidth = fulwdz + "px";
//        $(".fixed").css("width", fullwidth);
//    } else {
//        $('.opsrisk').removeClass('fixed');
//    }
//});


    $(".btn-group").hover(function () {
        $(".btn-group").removeClass("open");
        $(this).addClass("open");
    });
    $("*").click(function () {
        $(".btn-group").removeClass("open");
    });
    $(".clinick.invz .form-group.form-md-line-input.has-info").focusin(function () {
        $(this).children(".input-group-addon").css("z-index", "-500");
    });
    $(".clinick.invz .form-group.form-md-line-input.has-info").focusout(function () {
        $(this).children(".input-group-addon").css("z-index", "500");
    });
    $(".amrpop,input[type='text']:not(.datepicker),textarea").hover(function () {
        var pop_value = $(this).val();
        $(this).attr({
            "data-toggle": "popover",
            "data-trigger": "hover",
            "data-placement": "bottom",
            "data-content": pop_value
        });
        $(this).popover("show");
    });
    $(window).load(function () {
        $('input[type="search"]').attr("placeholder", "Search ..");
    });
    $(".focus-search-index").click(function () {
        $(this).hide();
        $(".xhide").hide();
        $(".indexsearchbox").css("z-index", "1");
    });
    $(document).keyup(function (e) {
        $(".focus-search-index").hide();
        //$(".xhide").hide();
        $(".indexsearchbox").css("z-index", "1");
    });


    var check_heigt_and_make_new_class = $(".check_heigt_and_make_new_class").height();
    if (check_heigt_and_make_new_class > 400) {
        $(".check_heigt_and_make_new_class").addClass("overflow_scroll");
    } else {
        $(".check_heigt_and_make_new_class").removeClass("overflow_scroll");
    }


    /***********/


//
//    $("input").hover(function () {
//        var xlabel = $(this).parent('#awval div').first().children('label').html();
//        $(this).parent('#awval div').first().children('label').hide()
//        $(this).attr("placeholder", xlabel);
//    });
//
//    $("input").hover(function () {
//        var xlabel = $(this).parent('#div_exmination div').first().children('label').html();
//        $(this).parent('#div_exmination div').first().children('label').hide()
//        $(this).attr("placeholder", xlabel);
//    });
//
//
//    $("input").hover(function () {
//        var xlabel = $(this).parent('.invz div').first().children('label').html();
//        $(this).parent('.invz div').first().children('label').hide()
//        $(this).attr("placeholder", xlabel);
//    });
//
//
//    $("input").hover(function () {
//        var xlabel = $(this).parent('.ng-pristine div').first().children('label').html();
//        $(this).parent('.ng-pristine div').first().children('label').hide()
//        $(this).attr("placeholder", xlabel);
//    });
//    
//    


    /***************************************************************/

    var showNum = 10;
    var showScrollLines = (showNum * 31) + 23;
    $(".showNum").height(showScrollLines);

    var showNumGyna = 10;
    var showScrollLines = (showNumGyna * 31) + 43;
    $(".showNumGyna").height(showScrollLines);


    /***********/


    $('body').on('keyup', '.save_complete_report_notes', function () {
        $text = $(this).val();
        $patient_id = $('#pNo').val();
        $hosturl = $('#hosturl').val();
        $.post($hosturl + '/controllers/completereport.php?ac=notescomplete', {text: $text, patient_id: $patient_id});
    })

    $('body').on('keyup', '.save_husband_patient_notes', function () {
        $text = $(this).val();
        $patient_id = $('#ptntid').val();
        $hosturl = $('#hosturl').val();
        $.post($hosturl + '/controllers/patients.php?ac=noteshusbands', {text: $text, patient_id: $patient_id});
    })


    $('body').on('keyup', '.save_husband_patient_habits', function () {
        $text = $(this).val();
        $patient_id = $('#ptntid').val();
        $hosturl = $('#hosturl').val();
        $.post($hosturl + '/controllers/patients.php?ac=habitshusbands', {text: $text, patient_id: $patient_id});
    })


});

$(document).ready(function () {
    $('.menu_role_item').change(function () {
        let check_val = $(this).val();
        let role_id = $('input[name=roleid]').val();
        let menu_id = $(this).attr('data-menuid');
        $.post(host_url + '/controllers/_role.php?ac=updateMenuSetting', {roleid: role_id, menuid: menu_id, menurolecheck: check_val}, function (result) {
            //alert(result);
        });
    });

    $('.control_prop_role_item').change(function () {
        let check_val = $(this).val();
        let role_id = $('input[name=roleid]').val();
        let control_prop_id = $(this).attr('data-controlpropid');
        $.post(host_url + '/controllers/_role.php?ac=updateControlSetting', {roleid: role_id, controllpropid: control_prop_id, proprolecheck: check_val}, function (result) {
            //alert(result);
        });
    });

    $('.btn_role_item').change(function () {
        let check_val = $(this).val();
        let role_id = $('input[name=roleid]').val();
        let btn_id = $(this).attr('data-btnid');
        $.post(host_url + '/controllers/_role.php?ac=updateBtnSetting', {roleid: role_id, btn_id: btn_id, btncheck: check_val}, function (result) {
            //alert(result);
        });
    });
});
