ok

Mini Shell

Direktori : /home2/selectio/public_html/obnovit-tracking/old/
Upload File :
Current File : /home2/selectio/public_html/obnovit-tracking/old/create-new-payslip.php

<?php  include "header.php";?>
<div class="content-wrapper" style="background:white;">
<script type="text/javascript">
   
</script>


<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div >
                <div class="box-header">

            
   <?php if($_SESSION['hrm']['id']==1 || $allPermissions['category']['create']=="1"){ ?> <?php } ?>
                    <h3 class="box-title"><b><i class="fa fa-list"></i> Pay Slip Creation </b></h3>
                </div>
                <div class="box-body">
<div class="row">
    <div class="col-sm-1">
<div class="form-group">
<label class="control-label" for="user">Year</label>
<select name="filter_year" class="form-control select2" style="width:100%" id="filter_year" required>
    <!--<option value="">All</option>-->
    <?php 
        for($i=2020;$i<=2040;$i++){
            if($i==date('Y')){
                echo "<option value='".$i."' selected>".str_pad($i, 2, "0", STR_PAD_LEFT)."</option>";
            }else{
                echo "<option value='".$i."'>".str_pad($i, 2, "0", STR_PAD_LEFT)."</option>";    
            }
            
        }
    ?>
</select>
</div>
</div>

<div class="col-sm-1">
<div class="form-group">
<label class="control-label" for="user">Month</label>
<select name="filter_month" class="form-control select2" style="width:100%" id="filter_month" required>
    <!--<option value="">All</option>-->
    <?php 
        for($i=1;$i<=12;$i++){
            if($i==date('m')){
                echo "<option value='".$i."' selected>".str_pad($i, 2, "0", STR_PAD_LEFT)."</option>";
            }else{
                echo "<option value='".$i."'>".str_pad($i, 2, "0", STR_PAD_LEFT)."</option>";    
            }
        }
    ?>
</select>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<label class="control-label" for="user">Department</label>
<select name="filter_year" class="form-control select2" style="width:100%" id="filter_department" required>
    <option value="all">All</option>
    <?php 
        $statement = $pdo->prepare("SELECT * FROM tbl_departement");
        $statement->execute();
        $result = $statement->fetchAll(PDO::FETCH_ASSOC);
        foreach ($result as $data) {
        echo "<option value=".$data['id'].">".$data['departement']."</option>";
    }?>
</select>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label class="control-label" for="user">Designation</label>
<select name="filter_year" class="form-control" style="width:100%" id="filter_designation" required>
    <option value="">All</option>
    
</select>
</div>
</div>

<div class="col-sm-3">
<div class="form-group">
<label class="control-label" for="user">Employee</label>
<select name="filter_created_by" class="form-control" style="width:100%" id="filter_employee" required>
    <option value="">All</option>
   
</select>
</div>
</div>

<div class="col-sm-2">
<div class="form-group">
<label class="control-label" for="user"></label>
<br><br><span class="btn btn-info btn-sm" id="btngetEmployee"><i class="fa fa-eye" aria-hidden="true"></i> Show Details</span>
</div>
</div>



</div>

<div class="clearfix"></div>
<div id="loading-div">
<center><img src="assets/load.gif" style="10%"><br>
<strong class="blink_me">Loading Pls Wait... </strong></center>
</div>
<div id="success_div">
    <center><img src="https://x-stream.co.za/inc/img/success.gif" style="width:10%;"><br><b>Payslip Generation Successfully Compeleted...</b></center>
</div>


<form action="" enctype="multipart/form-data" id="payslip_generate_form" method="post" accept-charset="utf-8">
<div id="pay_div">
    
</div>
</form>
</div>
               
            </div>
        </div>
    </div>
</section>

<style>
    .bold_value{
     font-weight:800;
     color:blue;
    }
</style>


<script>

function calculation_earning_reduction(emp_id){
    console.log('calculation Inprocess...');
    var count = $('input[name="create_earnings_name_'+emp_id+'[]"]').length;
    var create_earnings_percentage=0;var create_earnings_percentage_type=0;var create_earnings_subtotal=0;var create_earnings_total=0;create_reduction_total=0;is_ctc_total=0;pay_total=0;
    
    
    var net_salary =$('#net_salary_'+emp_id).val();
    
    for(var n=0;n<count;n++){
        var subtotal=0;
         var basic_salary=$('#basic_salary_'+emp_id).val();
        var earnings_percentage=$('#create_earnings_percentage_'+emp_id+'-'+n).val();
        var earnings_percentage_type=$('#create_earnings_percentage_type_'+emp_id+'-'+n).val();
        var is_basic_pay=$('#create_earnings_is_basic_pay_'+emp_id+'-'+n).val();
            if(earnings_percentage!=''){
                var salary_processing_days =$('#salary_processing_day'+emp_id).val();
                var avg_salary=(salary_processing_days)*(basic_salary/30);
                
                if(earnings_percentage==''){
                    $('#create_earnings_percentage_type_'+emp_id+'-'+n).val(0);
                    earnings_percentage=0;
                }
                
                if(earnings_percentage_type==1){
                    if(is_basic_pay==1){
                        subtotal=(earnings_percentage/100)*avg_salary;
                        $('#basic_pay_amt_'+emp_id).val(subtotal);
                    }else if(is_basic_pay==2){
                        var basic_pay_amt_=$('#basic_pay_amt_'+emp_id).val();
                        subtotal=(earnings_percentage/100)*basic_pay_amt_;
                    }
                }else{
                    subtotal=earnings_percentage;
                }
                create_earnings_total=(parseFloat(create_earnings_total))+(parseFloat(subtotal));
                $('#create_earnings_subtotal_txt_'+emp_id+'-'+n).text(parseFloat(subtotal).toFixed(2));
                $('#create_earnings_subtotal_'+emp_id+'-'+n).val(parseFloat(subtotal).toFixed(2));
            }
        
            }
    $('#create_earnings_total_txt_'+emp_id).text(parseFloat(create_earnings_total).toFixed(2));
    $('#create_earning_total'+emp_id).val(parseFloat(create_earnings_total).toFixed(2));
    
    var r_count = $('input[name="create_reduction_name_'+emp_id+'[]"]').length;
    
    for(var n=0;n<r_count;n++){
        console.log('reduction...'+n);
        var subtotal=0;
        var basic_salary=$('#basic_salary_'+emp_id).val();
        var reduction_percentage=$('#create_reduction_percentage_'+emp_id+'-'+n).val();
        var reduction_percentage_type=$('#create_reduction_percentage_type_'+emp_id+'-'+n).val();
        var is_ctc=$('#create_reduction_is_employer_ctc_'+emp_id+'-'+n).val();
        var create_reduction_is_basic_pay_=$('#create_reduction_is_basic_pay_'+emp_id+'-'+n).val();
        
        if(reduction_percentage!='')
        {    
            var salary_processing_days =$('#salary_processing_day'+emp_id).val();
            var avg_salary=(salary_processing_days)*(basic_salary/30);
            
            if(reduction_percentage_type==1){
                //if(create_reduction_is_basic_pay_==3){
                 var basic_pay_amt_=$('#basic_pay_amt_'+emp_id).val();
                    subtotal=(reduction_percentage/100)*basic_pay_amt_;
                   // $('#basic_pay_amt_'+emp_id).val(subtotal);
                // }else{
                //     var basic_pay_amt_=$('#basic_pay_amt_'+emp_id).val();
                //     subtotal=(earnings_percentage/100)*basic_pay_amt_;
                // }
            }else{
                subtotal=reduction_percentage;
            }
            if(is_ctc==1){
                console.log('ctc :'+subtotal)
                is_ctc_total=parseFloat(is_ctc_total)+parseFloat(subtotal);
            }
            
             create_reduction_total=(parseFloat(create_reduction_total))+(parseFloat(subtotal));
            $('#create_reduction_subtotal_txt_'+emp_id+'-'+n).text(parseFloat(subtotal).toFixed(2));
            $('#create_reduction_subtotal_'+emp_id+'-'+n).val(parseFloat(subtotal).toFixed(2));
        }
        
    }
    console.log('create_earnings_total :'+create_earnings_total+' is_ctc_total :'+is_ctc_total);
    $('#total_ctc_text_'+emp_id).text((parseFloat(create_earnings_total)+parseFloat(is_ctc_total)).toFixed(2));
    $('#create_reduction_total_txt'+emp_id).text(parseFloat(create_reduction_total).toFixed(2));
    $('#total_pay_to_employee_text_'+emp_id).text(parseFloat(parseFloat((parseFloat(create_earnings_total)+parseFloat(is_ctc_total)).toFixed(2))-parseFloat(create_reduction_total)).toFixed(2));
    
    $('#create_reduction_total_'+emp_id).val(parseFloat(create_reduction_total).toFixed(2));
    $('#total_ctc_'+emp_id).val((parseFloat(create_earnings_total)+parseFloat(is_ctc_total)).toFixed(2));
    $('#net_pay_to_employee_'+emp_id).val(parseFloat(parseFloat((parseFloat(create_earnings_total)+parseFloat(is_ctc_total)).toFixed(2))-parseFloat(create_reduction_total)).toFixed(2));
}



    $( document ).ready(function() {
        
        $('#success_div').hide();
        $('#loading-div').show();
        $('#content-div').hide();
        showData();
    
  
        function showData(){
            $('#loading-div').show();
            $('#content-div').hide();
            setTimeout(function() {
                $('#loading-div').hide();
                $('#pay_div').show('blind', {}, 500)
            }, 800);
        }
        
        
        
         $('#payslip_generate_form').on('submit', function(e){
             $('#success_div').hide();
                e.preventDefault();
                console.log('Form Submitted U can Enable Payslip Option...');
                var formData = new FormData(this);
                formData.append('type', 'Payslip_generation');
                                $.ajax({
                            url: 'api/payslip-generation-api.php',
                            type: 'post',
                            dataType: 'json',
                            data: formData,
                            cache: false,
                            contentType: false,
                            processData: false,
                          enctype: 'multipart/form-data',
                            success: function (response) {
                                console.log(response);
                               $('#success_div').show();
                                $('#pay_div').empty();
                            }
                        });
                
    });             
            
    
});
</script>
<script>
 function add_new_row_earnings(ids){
     console.log('working fine');
    html = '<div class="row" style="margin-top:10px; "><div class="col-sm-6"><input style="height:25px!important; font-size:12px;" type="text" name="create_earnings_name[]"  placeholder="Enter Earnings Name" class="form-control tip input-xs" id="create_earnings_name"  required="required"/></div><div class="col-sm-4"><input style="height:25px!important;font-size:12px;" type="number" name="create_earnings_percentage[]"  placeholder="Enter Earnings Percentage" class="form-control tip input-xs" id="create_earnings_percentage"  required="required" /></div><div class="col-sm-2"><button class="btn btn-danger btn-xs remove_allowance"><i class="fa fa-trash-o"></i></button></div></div>';
        $('#earnings_rows_'+ids).append(html);
}
function add_new_row_reduction(idr){
     console.log('working fine');
    html = '<div class="row" style="margin-top:10px;"><div class="col-sm-6"><input style="height:25px!important;font-size:12px;" type="text" name="create_reduction_name[]"  placeholder="Enter Reduction Name" class="form-control tip input-xs" id="update_reduction_name"  required="required" /></div><div class="col-sm-4"><input style="height:25px!important;font-size:12px;" type="number" name="create_reduction_percentage[]"  placeholder="Enter Reduction Percentage" class="form-control tip input-xs" id="update_reduction_percentage"  required="required" /></div><div class="col-sm-2"><button class="btn btn-danger btn-xs remove_reduction"><i class="fa fa-trash-o"></i></button></div></div>';
        $('#reduction_rows_'+idr).append(html);
}

    $(document).on('click', '.remove_allowance', function() {
        $(this).closest('.row').remove();
    });
    $('#add_new_row_earnings').on('click', function() {
        html = '<div class="row" style="margin-top:10px; "><div class="col-sm-6"><input style="height:25px!important; font-size:12px;" type="text" name="create_earnings_name[]"  placeholder="Enter Earnings Name" class="form-control tip input-xs" id="create_earnings_name"  required="required"/></div><div class="col-sm-4"><input style="height:25px!important;font-size:12px;" type="number" name="create_earnings_percentage[]"  placeholder="Enter Earnings Percentage" class="form-control tip input-xs" id="create_earnings_percentage"  required="required" /></div><div class="col-sm-2"><button class="btn btn-danger btn-xs remove_allowance"><i class="fa fa-trash-o"></i></button></div></div>';
        $('#earnings_rows').append(html);
    });
    
    $(document).on('click', '.remove_reduction', function() {
        $(this).closest('.row').remove();
    });
    $('#add_new_row_reduction').on('click', function() {
        html = '<div class="row" style="margin-top:10px;"><div class="col-sm-6"><input style="height:25px!important;font-size:12px;" type="text" name="create_reduction_name[]"  placeholder="Enter Reduction Name" class="form-control tip input-xs" id="update_reduction_name"  required="required" /></div><div class="col-sm-4"><input style="height:25px!important;font-size:12px;" type="number" name="create_reduction_percentage[]"  placeholder="Enter Reduction Percentage" class="form-control tip input-xs" id="update_reduction_percentage"  required="required" /></div><div class="col-sm-2"><button class="btn btn-danger btn-xs remove_reduction"><i class="fa fa-trash-o"></i></button></div></div>';
        $('#reduction_rows').append(html);
    });
</script>

<script>
 $(document).ready(function(){ 
     
    $("#filter_department").change(function () {
        $('#success_div').hide();
        get_desgination();
    });
    $("#filter_designation").change(function () {
        $('#success_div').hide();
        get_employee_by_designation_id();
    });
    
    function get_desgination(){
        $('#success_div').hide();
         $('#filter_designation').empty();
        var departement_id=$('#filter_department').val();
                                $.ajax({
                            url: 'api/get-desgination-api.php',
                            type: 'post',
                            dataType: 'json',
                            data: {type:'get_desgination',departement_id:departement_id},
                            success: function (response) {
                                //console.log(response);
                                var m='<option value="all">All</option>';
                                if(response['error']==false){
                                    for(var n=0;n<response['data'].length;n++){
                                        m+='<option value='+response['data'][n]['id']+'>'+response['data'][n]['desgination']+'</option>';
                                    }
                                }
                                $('#filter_designation').append(m);  
                                
                               
                            }
                        });
    }
    
    function get_employee_by_designation_id(){
         $('#filter_employee').empty();
        var designation_id=$('#filter_designation').val();
                                $.ajax({
                            url: 'api/get_employee_by_designation_id.php',
                            type: 'post',
                            dataType: 'json',
                            data: {type:'get_employee_by_designation_id',designation_id:designation_id},
                            success: function (response) {
                             //   console.log(response);
                                var m='<option value="all">All</option>';
                                if(response['error']==false){
                                    for(var n=0;n<response['data'].length;n++){
                                        m+='<option value='+response['data'][n]['id']+'>'+response['data'][n]['emp_name']+'</option>';
                                    }
                                }
                                $('#filter_employee').append(m);  
                                
                               
                            }
                        });
    }
    
    
    $("#btngetEmployee").click(function () {
        get_payslip_info();
        $('#loading-div').show();
            $('#pay_div').hide();
            setTimeout(function() {
                $('#loading-div').hide();
                $('#pay_div').show('blind', {}, 500)
            }, 800);
    });
    
    function get_payslip_info(){
        $('#pay_div').empty();
        var filter_department =$('#filter_department').val();
            var filter_designation =$('#filter_designation').val();
            var filter_employee =$('#filter_employee').val();
            var filter_year =$('#filter_year').val();
            var filter_month =$('#filter_month').val();
        
                                $.ajax({
                            url: 'api/get-payslip-generation-emp-list.php',
                            type: 'post',
                            dataType: 'json',
                            data:{filter_department:filter_department,filter_designation:filter_designation,filter_employee:filter_employee,filter_year:filter_year,filter_month:filter_month}, 
                            success: function (response) {
                                //console.log(response);
                                $('#pay_div').append(response['data']);
                                }
                        });
    }
    
 });   
function isNumberKey(txt, evt) {
      var charCode = (evt.which) ? evt.which : evt.keyCode;
      if (charCode == 46) {
        //Check if the text already contains the . character
        if (txt.value.indexOf('.') === -1) {
          return true;
        } else {
          return false;
        }
      } else {
        if (charCode > 31 &&
          (charCode < 48 || charCode > 57))
          return false;
      }
      return true;
    }
    
</script>
<?php include "footer.php";?>

Zerion Mini Shell 1.0