<style>
.modal-open .modal {
    overflow-x: hidden;
    overflow-y: hidden;
}
</style>
<div class="modal-dialog modal-lg" role="document" id="add_modal" style="overflow-x: hidden; overflow-y: hidden; width: 70%;">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title mt-0" id="myLargeModalLabel"><b>Create Customers Details</b></h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close" style="margin-top: -25px;"><i class="fa fa-times"></i></button>
            </div>
            
            <form id="form_detailss">
            <div id="content-divv">
            
            
            <div class="modal-body" style="padding: 20px 40px 20px 40px;">
                
                    <div class="row">
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label class="required" for="customer_name">Customer Name</label>                                    
                                        <input type="text" name="customer_name" value="" placeholder="Enter the Customer Name" class="form-control" id="customer_name"  required="required" />
                                    </div>
                                </div>
                                
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label class="required" for="mobile_no">Mobile Number</label>                                    
                                        <input type="text" name="mobile_no" value="" placeholder="Enter the Mobile Number" class="form-control" id="mobile_no"  required="required"  onkeypress="return isNumberKey(this, event);"/>
                                    </div>
                                </div>
                                
                                <div class="col-lg-3">
                                    <div class="form-group mb-4">
                                        <label class="required" for="city_town">City/Town</label>
                                        <input type="text" name="city_town" value="" class="form-control" id="city_town" placeholder="City/Town">
                                    </div>
                                </div>
                                
                                
                                
                                
                              
                                
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label class="required" for="gender">Gender</label>
                                        <select name="gender" id="gender" class="form-control select2">
                                            <option value="Male">Male</option>
                                            <option value="Female">Female</option>
                                        </select>
                                    </div>
                                </div>
                                
                                
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label class="optional" for="alter_mobile_no">Alter Mobile Number</label>                                    
                                        <input type="text" name="alter_mobile_no" value="" placeholder="Alter Mobile Number" class="form-control" id="alter_mobile_no"   />
                                    </div>
                                </div>
                                            
                                
                               
                                
                                            <div class="col-lg-3">
                                                <div class="form-group mb-4">
                                                    <label for="dob">Date of Birth</label>
                                                    <input type="date" name="dob" class="form-control" id="dob">
                                                </div>
                                            </div>
                                            
                                            <div class="col-lg-3">
                                                <div class="form-group mb-4">
                                                    <label for="wedding_date">Wedding Date</label>
                                                    <input type="date" name="wedding_date" class="form-control" id="wedding_date">
                                                </div>
                                            </div>
                                            
                                            <div class="col-lg-3">
                                                <div class="form-group mb-4">
                                                    <label for="religion">Religion </label>
                                                    <select name="religion" id="religion" class="form-control select2">
                                                        <option value="">Select Religion</option>
                                                        <option value="Hindu">Hindu</option>
                                                        <option value="Muslim">Muslim</option>
                                                        <option value="Christian">Christian</option>
                                                    </select>
                                                </div>
                                            </div>
                                            
                                            
                                            <div class="col-lg-3">
                                                <div class="form-group mb-4">
                                                    <label for="pan_no">Pan Number</label>
                                                    <input type="text" name="pan_no" class="form-control" id="pan_no" placeholder="Pan Number">
                                                </div>
                                            </div>
                                            
                                            
                                            <div class="col-lg-3">
                                                <div class="form-group mb-4">
                                                    <label for="aadhaar_no">Aadhaar Number</label>
                                                    <input type="text" name="aadhaar_no" class="form-control" id="aadhaar_no" placeholder="Aadhaar Number" onkeypress="if(this.value.length==12) return false;return isNumber(event);">
                                                </div>
                                            </div>
                                            
                                            <div class="col-lg-3">
                                                <div class="form-group mb-4">
                                                    <label for="gst_no">GST Number</label>
                                                    <input type="text" name="gst_no" class="form-control" id="gst_no" value="" placeholder="GST Number">
                                                </div>
                                            </div>
                                            
                                            
                                            <div class="col-lg-3">
                                                <div class="form-group mb-4">
                                                    <label for="address">Address</label>
                                                    <textarea type="text" name="address" rows="5" class="form-control" id="address" placeholder="Address"></textarea>
                                                </div>
                                            </div>
                          
                                
                                
                                
                                
                            </div>
                            
                            
               

            </div>
            
            <div class="modal-footer">
                <button type="submit" id="submit" class="btn btn-primary">Create</button>
            </div>
            
            
            </div>
            </form>
            
            
            
            <div id="loading-divv" style="display: none; padding-bottom: 80px;">
                    <center> <img src="img/loading.gif" style="width: 250px;"><br><b class="blinking">Processing Please Wait...</b></center>
            </div>
            
            
            
        </div>
    </div>
    
<script>
   $('#form_detailss').on('submit', function(e){
                e.preventDefault();
                $('#loading-divv').show();
                $('#content-divv').hide();
                $("#submit").prop('disabled', true);
                var formData = new FormData(this);
                formData.append('type', 'create_customers');
                    $.ajax({
                            url: 'apis/customers.php',
                            type: 'post',
                            dataType: 'json',
                            data: formData,
                            cache: false,
                            contentType: false,
                            processData: false,
                            enctype: 'multipart/form-data',
                            success: function (response) {
                                console.log(response);
                                if(response['status']==200){
                                     /*alert(response['message']);*/
                                     
                                     $("#add_modal .close").click();
                                     $('#form_details').trigger("reset");
                                     $('#loading-divv').hide();
                                     $('#content-divv').show();
                                     $('#customer_id').append('<option value='+response['customer_id']+'>'+response['customer_name']+' - '+response['mobile_no']+'</option>');
                                     $('#customer_id').val(response['customer_id']).trigger('change');
                                     
                                     
                                }else{
                                    alert(response['message']);
                                    $("#submit").prop('disabled', false);
                                    $('#loading-divv').hide();
                                    $('#content-divv').show();
                                }
                            }
                        });
   });


/*$('#form_detailss').on('submit', function(e){
        console.log("Click And Form Working");
                e.preventDefault();
                $('#loading-div').show();
                $('#content-div').hide();
                var formData = new FormData(this);
                formData.append('type', 'create_gst');
                            $.ajax({
                            url: 'apis/customss.php',
                            type: 'post',
                            dataType: 'json',
                            data: formData,
                            cache: false,
                            contentType: false,
                            processData: false,
                            enctype: 'multipart/form-data',
                            success: function (response) {
                                if(response['status']==200){
                                     alert(response['message']);
                                     $("#add_modal .close").click();
                                     $('#add_form').trigger("reset");
                                     emp_datas();
                                     $('#loading-div').hide();
                                     $('#content-div').show();
                                }else{
                                    alert(response['message']);
                                    $('#loading-div').hide();
                                    $('#content-div').show();
                                }
                                
                               
                            }
                        });
                
    });*/
    
    

/*$('#add_form').on('submit', function(e){
        console.log("Click And Form Working");
                e.preventDefault();
                $('#loading-div').show();
                $('#content-div').hide();
                var formData = new FormData(this);
                formData.append('type', 'create_customer');
                            $.ajax({
                            url: 'apis/customer-add-api.php',
                            type: 'post',
                            dataType: 'json',
                            data: formData,
                            cache: false,
                            contentType: false,
                            processData: false,
                            enctype: 'multipart/form-data',
                            success: function (response) {
                                if(response['status']==200){
                                     alert(response['message']);
                                     $("#add_modal .close").click();
                                     $('#add_form').trigger("reset");
                                     $('#loading-div').hide();
                                     $('#content-div').show();
                                     $('#customer').append('<option value='+response['id']+'>'+response['last_name']+'</option>');
                                     $('#customer').val(response['id']).trigger('change');
                                }else{
                                    alert(response['message']);
                                    $('#loading-div').hide();
                                    $('#content-div').show();
                                }
                                
                               
                            }
                        });
                
    });*/
</script>
