ok

Mini Shell

Direktori : /home2/selectio/public_html/tnpsctestbatch.com/admin/old/api/backups/
Upload File :
Current File : /home2/selectio/public_html/tnpsctestbatch.com/admin/old/api/backups/payslip-generation-api.php

<?php
session_start(); 
include"../config/config.php";
//if(isset($_POST['employe_id']) && $_POST['type']=='Payslip_generation'){
        try{
            
            $query="INSERT INTO `tbl_payslip_generation`(`employee_id`, `basic_salary`, `pf_type`, `month`, `year`, `working_days`, `special_holidays`, `holidays`, `permission_leaves`, `salary_processing_days`,final_salary_processing_days, `net_salary`, `earnings_total`, `reduction_total`, `total_ctc`, `net_pay_employee`, `earnings_details`, `reduction_details`,extra_working_updated_column_leave,common_leave_taken,common_leave_added,cumulative_leave_add,cumulative_leave_taken,casual_leave_add,casual_leave_taken,advanced_reduction_amt) VALUES";
            $query_array=array();
            $querys='';
            for($i=0;$i<count($_POST['employee_id']);$i++){
                $earning_details=array();$reduction_details=array();
                $employee_id=$_POST['employee_id'][$i];
                $nam='create_earnings_name_'.$employee_id;
                $count=count($_POST[$nam]);
                for($v=0;$v<count($_POST[$nam]);$v++){
                    $earning_details[]=array($_POST['create_earnings_name_'.$employee_id][$v], $_POST['create_earnings_percentage_'.$employee_id][$v],$_POST['create_earnings_percentage_type_'.$employee_id][$v],$_POST['create_earnings_subtotal_'.$employee_id][$v]);
                    
                }
                $nam='create_reduction_name_'.$employee_id;
                $count=count($_POST[$nam]);
                 for($s=0;$s<$count;$s++){
                  $reduction_details[]=array($_POST['create_reduction_name_'.$employee_id][$s], $_POST['create_reduction_percentage_'.$employee_id][$s],$_POST['create_reduction_percentage_type_'.$employee_id][$s],$_POST['create_reduction_subtotal_'.$employee_id][$s]);
                }
                
                
                $query_array[]="('".$_POST['employee_id'][$i]."','".$_POST['basic_salary'][$i]."','".$_POST['pf_type'][$i]."','".$_POST['month'][$i]."','".$_POST['year'][$i]."','".$_POST['working_days'][$i]."','".$_POST['special_holidays'][$i]."','".$_POST['holiday'][$i]."','".$_POST['permission_leave'][$i]."','".$_POST['salary_processing_day'][$i]."','".$_POST['final_salary_processing_day'][$i]."','".$_POST['net_salary'][$i]."','".$_POST['create_earning_total'][$i]."','".$_POST['create_reduction_total'][$i]."','".$_POST['total_ctc'][$i]."','".$_POST['net_pay_to_employee'][$i]."','".json_encode($earning_details)."','".json_encode($reduction_details)."','".$_POST['extra_working_days'][$i]."','".$_POST['used_common_leave'][$i]."','".$_POST['extra_working_days'][$i]."','".$_POST['add_cumulative'][$i]."','".$_POST['use_cumulative'][$i]."','".$_POST['add_casual'][$i]."','".$_POST['use_casual'][$i]."','".$_POST['salary_advance'][$i]."')"; 
                //insert Details
               
               
               //update Extra leave Details Here
               /*if($_POST['extra_working_days'][$i]>0){
                   $statement = $pdo->prepare("UPDATE `tbl_user` SET `common_leave`=common_leave+ ? WHERE id=?");
                    $result=$statement->execute(array($_POST['extra_working_days'][$i],$_POST['employee_id'][$i]));
                   // UPDATE tbl_user SET common_leave = common_leave + 7 WHERE id = 68
               }*/
               
               
               //update Cumulative add leave Details Here
               if($_POST['add_cumulative'][$i]>0){
                   $statement = $pdo->prepare("UPDATE `tbl_user` SET `cumulative_leave`=cumulative_leave+ ? WHERE id=?");
                    $result=$statement->execute(array($_POST['add_cumulative'][$i],$_POST['employee_id'][$i]));
                   // UPDATE tbl_user SET common_leave = common_leave + 7 WHERE id = 68
               }
               
               //update Casual add leave Details Here
               if($_POST['add_casual'][$i]>0){
                   $statement = $pdo->prepare("UPDATE `tbl_user` SET `casual_leave`=casual_leave+ ? WHERE id=?");
                    $result=$statement->execute(array($_POST['add_casual'][$i],$_POST['employee_id'][$i]));
                   // UPDATE tbl_user SET common_leave = common_leave + 7 WHERE id = 68
               }
               
               /*if($_POST['used_common_leave'][$i]>0){
                   $statement = $pdo->prepare("UPDATE `tbl_user` SET `common_leave`=common_leave- ? WHERE id=?");
                    $result=$statement->execute(array($_POST['used_common_leave'][$i],$_POST['employee_id'][$i]));
                   // UPDATE tbl_user SET common_leave = common_leave + 7 WHERE id = 68
               }*/
               
               //update Cumulative add leave Details Here
               if($_POST['use_cumulative'][$i]>0){
                   $statement = $pdo->prepare("UPDATE `tbl_user` SET `cumulative_leave`=cumulative_leave- ? WHERE id=?");
                    $result=$statement->execute(array($_POST['use_cumulative'][$i],$_POST['employee_id'][$i]));
                   // UPDATE tbl_user SET common_leave = common_leave + 7 WHERE id = 68
               }
               
               //update Casual add leave Details Here
               if($_POST['use_casual'][$i]>0){
                   $statement = $pdo->prepare("UPDATE `tbl_user` SET `casual_leave`=casual_leave- ? WHERE id=?");
                    $result=$statement->execute(array($_POST['use_casual'][$i],$_POST['employee_id'][$i]));
                   // UPDATE tbl_user SET common_leave = common_leave + 7 WHERE id = 68
               }
               
            
               
                
            }
            $querys=implode(',', $query_array);
            $query.=$querys;
             $statement = $pdo->prepare($query);
                $result=$statement->execute();
                 // $result=1;
             
                    if($result){
                        error_log('uery :'.$query);
                        $return_arr['message'] = 'Pay Slip added successfully!';
                        $return_arr['status']=200;
                          
                    }else{
                        $return_arr['message']="Something went wrong try again...";
                        $return_arr['status']=400;
                    }  
                }catch(Exception $e){
                    $return_arr['message']='0987'.$e;
                    $return_arr['status']=500;
                }   
                echo json_encode($return_arr);
   // }

?>

Zerion Mini Shell 1.0