<style>
#defination{
  display:none;
}
#back{
  display:none;
}
</style>
<link href="<?php echo base_url(); ?>assets/vendors/select2/dist/css/select2.min.css" rel="stylesheet">
 <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
                <div class="title_left">
                
                    <h3 style="float:right">Provident Fund</h3>
                   
                </div>
            </div>
            <div class="clearfix"></div>
      <div class="row" id="Allowance">

                 <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Add Provident Fund</h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                     <?php if ($this->session->flashdata('errormsgded')): ?>
<div class="alert alert-success">
<?php echo $this->session->flashdata('errormsgded'); ?>
</div>
<?php endif ?>
   <?php if ($this->session->flashdata('errormsg2ded')): ?>
<div class="alert alert-danger">
<?php echo $this->session->flashdata('errormsg2ded'); ?>
</div>
<?php endif ?>
                  <div class="x_content">

                    <form class="form-horizontal form-label-left" action="<?php echo $base_url; ?>Salary/saveprovident_add" method="post">
                        
                       <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Type<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-6">
                            <select class="form-control" required name="type" id="type">
                              <option value=''>Select Type</option>
                              <option value='teacher'>Teacher</option>
                              <option value='staff'>Staff</option>
                              
                                                </select> 
                           </div>
                      </div>
              
                     <div class="item form-group" id="myemp">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Employee Name<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-6">
                            <select class="form-control" required name="emp" id="empee">
                              <option value=''>Select Employee</option>
                                                </select> 
                           </div>
                      </div>
                     
                      <div class="item form-group">
                       <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Month<span class="required"></span>
                        </label>
                         <div class="col-md-6 col-sm-6 col-xs-6">
                        <input type="month" class="form-control" name="month" id="month" required>
                        </div>
                     </div>
                     
                      <div class="item form-group res">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="b_h_contact">Employee<span class="required">*</span>
                        </label>
                        <div class="col-md-4 col-sm-4 col-xs-12">
           
                          <input type="text" class="form-control"  placeholder="Amount"  onclick="Rup2(event)" id="allowance_rup2" name="allowance_amount22" required>
                     
                       </div>
                         
                        </div>
                        
                          <div class="item form-group res">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="b_h_contact">Employer<span class="required">*</span>
                        </label>
                        <div class="col-md-4 col-sm-4 col-xs-12">
           
                          <input type="text" class="form-control"  placeholder="Amount"  onclick="Rup2(event)" id="allowance_rup2" name="allowance_amount221" required>
                     
                       </div>
                         
                        </div>
                      
                      <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
                          <button id="save" type="submit" class="btn btn-success">Save</button>
                        </div>
                      </div>
                    </form>
                  </div>
                </div>
              </div>    
            </div>


 <div class="row" class="col-lg-12" id="assigned_allownce">
             <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>View Employee PF</h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                  <div class="x_content">
                     <div class="row">
                        
                    <table id="datatable2"  class="table">
                      <thead>
                        <tr>
                          <th style="width:100px;">#</th>
                          <th style="width:100px;">Name</th>
                          <th style="width:100px;">Month</th>
                          <th style="width:100px;">Employee</th>
                          <th style="width:100px;">Employer</th>
                        </tr>
                      </thead>
 

                      <tbody class="center22">
                    
                    
                      </tbody>
                   </table>

                  </div>
                    
                  </div>
                </div>
             
              </div>
              </div>
            </div>





          </div>
        </div>
        <!-- /page content -->
     
<script src="<?php echo base_url(); ?>assets/vendors/jquery/dist/jquery.min.js"></script>
<script src="<?php echo base_url(); ?>assets/vendors/select2/dist/js/select2.full.min.js"></script>
  <script>
window.setTimeout(function() {
$(".alert").fadeTo(500, 0).slideUp(500, function(){
    $(this).remove(); 
});
}, 3000);
</script>
    <!-- Datatables -->
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.print.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-scroller/js/datatables.scroller.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/jszip/dist/jszip.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/pdfmake/build/pdfmake.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/pdfmake/build/vfs_fonts.js"></script>

    

    <!-- Datatables -->
     <script>
     $(document).ready(function() {
    $('#datatable').DataTable();
           });
 </script>

  <script>
     $(document).ready(function() {
    $('#datatable2').DataTable();
           });
 </script>
    <!-- /Datatables -->

<script>
function Rup2(event){
  event.preventDefault();
 
 $("#allowance_rup2").keypress(function(event){
  var inputValue = event.which;
  if (inputValue != 8 && inputValue != 0 && (inputValue < 48 || inputValue > 57)) {
        //display error message
        alert("Please press only digit..");
               return false;
    }
 });
}
</script>


 <script>

    $('#type').change(function() {
 var c=$(this).val();
   
   if(c=="teacher"){
      $.ajax({
            url: "<?php echo base_url();?>Load/checkval/"+c, 
          success: function(result){
             // alert(result);
                $("#empee").html(result);
                jq('#empee').multiselect('reload');
                
            }}
            );
       $.ajax({
     url: '<?php echo base_url(); ?>Salary/load_teacher_addpf/',
      success: function (result) {
           $("#datatable2").dataTable().fnDestroy();
           setTimeout(function(){ 
                $("tbody.center22").html(result);
                $('#datatable2').DataTable();
            },500);
           }
      });


   }else{
      $.ajax({
            url: "<?php echo base_url();?>Load/checkval1/"+c, 
          success: function(result){
                $("#empee").html(result);
                jq('#empee').multiselect('reload');
                
            }});
             
             $.ajax({
     url: '<?php echo base_url(); ?>Salary/load_staff_addpf/',
      success: function (result) {
           $("#datatable2").dataTable().fnDestroy();
           setTimeout(function(){ 
                $("tbody.center22").html(result);
                $('#datatable2').DataTable();
            },500);
           }
      });


    }
        
        
        $("#empee").select2({
          
        });
     

            //loading form again
            $.ajax({
    url: '<?php echo base_url(); ?>Salary/alldeductions/',data: {},
         success: function (result) {
               $("#get_data").html(result);
           }
     });//end ajax for loading form

  });
   


 
  $("#myemp").change(function() {
  
                    var value = $('#empee').val();
                    var ref=$('#type').val();
                   
                    $.ajax({
     url: '<?php echo base_url(); ?>Salary/teacher_addpf_selected/'+value+"/"+ref,
      success: function (result) {
           $("#datatable2").dataTable().fnDestroy();
           
           setTimeout(function(){ 
                $("tbody.center22").html(result);
                $('#datatable2').DataTable();
            },500);
           }
      });

                  if(ref=='teacher')
                  {
                     $.ajax({
                      url: "<?php echo base_url();?>Salary/teacher_pfadd/"+value,
                     success: function(result){
                   if(result != '')
                   {
                       alert("You already Add Provident fund of this employee");
                        $("#save").attr("disabled",true);
                    
                   }
                   else
                   {
                        $("#save").attr("disabled",false);
                   }   
                         }
                         });
                          
              
                  }else
                  {
                     // alert(value);
                     $.ajax({
                      url: "<?php echo base_url();?>Salary/staff_pfadd/"+value,
                     success: function(result){
                   // $("#empee").html(result);
                   if(result != '')
                   {
                        alert("You already Add Provident fund of this employee");
                        $("#save").attr("disabled",true);
                     
                   }
                   else
                   {
                        $("#save").attr("disabled",false);
                   }
                         }
                         }); 
                  }

                     
                    }); 
 


  </script> 