/* 
 * 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.
 */

function autoSelectNextDate(elem) {
    $("input[name=next_section_date]").val('');
    var value = $(elem).val();
    if (value) {
        var currentdate = new Date();
        var new_date = currentdate.setDate(currentdate.getDate() + parseInt(value));
        var date = moment(new_date).format("YYYY-MM-DD");
        $(".date-only").datepicker('update', date);
    }
}

function getSttInfo(member_id = 0, client_id = 0, URL = "") {
    event.preventDefault();
    if(client_id == 0){
        client_id = $('#client-contact-id').find(':selected').attr('data-id');
    }

    if (client_id > 0) {
        
        $('.loading').show();
        
        if(!URL){
           URL = APP_SERVER_HOST_URL+'/Staff/getSertgInfo.php';
        }
        
        var formData = {};
        formData['client_id'] = client_id;
        formData['member_id'] = member_id;
        if(member_id == 0){
            formData['member_id'] = $('input[name=member_id]').val();
        }
        formData['formdata'] = "STT_PI_LETTER_SET";

        $.ajax({
            type: 'POST',
            url: URL,
            data: formData,
            cache: false,
            success: function (data) {
                $('.loading').hide();
                data = JSON.parse(data);
console.log(data,formData)
                if (data['status']) {
                    $('#stt-info .modal-body').html(data['html'])
                    $('#stt-info').modal('show')
                }
            }
        });
    }

}

