ok
Direktori : /proc/thread-self/root/home2/selectio/www/obnovit-tracking/old/ |
Current File : //proc/thread-self/root/home2/selectio/www/obnovit-tracking/old/pf-structure.php |
<?php include "header.php"; $base_value=''; if(isset($_POST['create_update_pf_structure'])){ $base_query="INSERT INTO `tbl_pf_details`(`name`, `type`, `percentage`, `pf_type_id`) VALUES"; $base_value=array(); for($i=0;$i<count($_POST['create_allowance_name']);$i++){ $base_value[]="('".$_POST['create_allowance_name'][$i]."','1','".$_POST['create_allowance_percentage'][$i]."','".$_POST['filter_pf_type']."')"; } for($i=0;$i<count($_POST['create_deduction_name']);$i++){ $base_value[]="('".$_POST['create_deduction_name'][$i]."','2','".$_POST['create_deduction_percentage'][$i]."','".$_POST['filter_pf_type']."')"; } for($i=0;$i<count($_POST['update_allowance_name']);$i++){ $statement = $pdo->prepare("UPDATE tbl_pf_details SET name=?,type=?,percentage=?,pf_type_id=? WHERE id=?"); $result=$statement->execute(array($_POST['update_allowance_name'][$i],'1',$_POST['update_allowance_percentage'][$i],$_POST['filter_pf_type'],$_POST['update_alowance_id'][$i])); } for($i=0;$i<count($_POST['update_deduction_name']);$i++){ $statement = $pdo->prepare("UPDATE tbl_pf_details SET name=?,type=?,percentage=?,pf_type_id=? WHERE id=?"); $result=$statement->execute(array($_POST['update_deduction_name'][$i],'2',$_POST['update_deduction_percentage'][$i],$_POST['filter_pf_type'],$_POST['update_deduction_id'][$i])); } $string_version = implode(',', $base_value); $base_query.=$string_version; if(count($base_value)){ $statement = $pdo->prepare($base_query); $result=$statement->execute(); } } ?> <div class="content-wrapper" style="background:white;"> <div class="clearfix"></div> <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> Pf Structure</b></h3> </div> <div class="box-body"> <form action="" method="post"> <div class="row"> <div class="col-sm-3"> <div class="form-group"> <label class="control-label required" for="user">Select BF Type</label> <select name="filter_pf_type" class="form-control select2" style="width:100%" id="filter_pf_type" required> <?php $statement = $pdo->prepare("SELECT * FROM tbl_pf_type"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach($result as $com_user){ echo "<option value='".$com_user['id']."'>".$com_user['type_name']."</option>"; } ?> </select> </div> </div> </div> <div class="clearfix"></div> <center><h4 class="box-title"><b><i class="fa fa-list"></i> Update Allowance & Deduction Information Details </b></h4></center> <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="content-div"> <div class="row"> <div class="col-sm-6"> <center><h5 class="box-title"><b><i class="fa fa-list"></i> Allowance </b></h5></center> <div id="update_allowance_rows"> </div> <div id="allowance_rows"> </div> <div class="row"><br><center><span id="add_new_row_earnings" class="btn btn-warning btn-sm"><i class="fa fa-plus"></i> Add New Row</span></center></div> </div> <div class="col-sm-6"> <center><h5 class="box-title"><b><i class="fa fa-list"></i> Deduction</b></h5></center> <div id="update_deduction_rows"> </div> <div id="deduction_rows"> </div> <div class="row"><br><center><span id="add_new_row_reduction" class="btn btn-warning btn-sm"><i class="fa fa-plus"></i> Add New Row</span></center></div> </div> </div> <center><button class="btn btn-success btn-sm" name="create_update_pf_structure"><i class="fa fa-save"></i> Update PF Structure</button></center> </form> </div> </div> </div> </div> </div> </section> <script> $( document ).ready(function() { $('#loading-div').show(); $('#content-div').hide(); showData(); get_data(); $('#filter_pf_type').on('change',function(){ get_data(); showData(); }); function get_data(){ $("#allowance_rows").empty(); $("#deduction_rows").empty(); $("#update_allowance_rows").empty(); $("#update_allowance_rows").empty(); var pf_type_id=$('#filter_pf_type').val(); // formData.append('type', 'get_pf_structure'); $.ajax({ url: 'api/get-pf-structure.php', type: 'post', dataType: 'json', data: {type:'get_pf_structure',pf_type_id:pf_type_id}, success: function (response) { console.log(response); if(response['error']==false){ for(var i=0;i<response['data'].length;i++){ if(response['data'][i]['type']==1){ if(response['data'][i]['is_basic_pay']==0 && response['data'][i]['is_employer_ctc']==0){ html = '<div class="row" style="margin-top:10px;"><div class="col-sm-6"><input type="text" name="update_alowance_id[]" value="'+response['data'][i]['id']+'" hidden> <input type="text" name="update_allowance_name[]" placeholder="Enter Allowance Name" class="form-control tip input-sm" id="update_allowance_name" value="'+response['data'][i]['name']+'" required="required" /></div><div class="col-sm-4"><input type="number" name="update_allowance_percentage[]" placeholder="Enter Allowance Percentage" class="form-control tip input-sm" id="update_allowance_percentage" value="'+response['data'][i]['percentage']+'" required="required" /></div><div class="col-sm-2"><button class="btn btn-danger btn-sm"><i class="fa fa-trash-o"></i></button></div></div>'; }else{ html = '<div class="row" style="margin-top:10px;"><div class="col-sm-6"><input type="text" name="update_alowance_id[]" value="'+response['data'][i]['id']+'" hidden> <input type="text" name="update_allowance_name[]" readonly placeholder="Enter Allowance Name" class="form-control tip input-sm" id="update_allowance_name" value="'+response['data'][i]['name']+'" required="required" /></div><div class="col-sm-4"><input type="number" name="update_allowance_percentage[]" placeholder="Enter Allowance Percentage" class="form-control tip input-sm" id="update_allowance_percentage" value="'+response['data'][i]['percentage']+'" required="required" /></div><div class="col-sm-2"></div></div>'; } $('#update_allowance_rows').append(html); }else{ if(response['data'][i]['is_basic_pay']==0 && response['data'][i]['is_employer_ctc']==0){ html = '<div class="row" style="margin-top:10px;"><div class="col-sm-6"><input type="text" name="update_deduction_id[]" value="'+response['data'][i]['id']+'" hidden><input type="text" name="update_deduction_name[]" placeholder="Enter Deduction Name" class="form-control tip input-sm" id="update_deduction_name" value="'+response['data'][i]['name']+'" required="required" /></div><div class="col-sm-4"><input type="number" name="update_deduction_percentage[]" placeholder="Enter Deduction Percentage" class="form-control tip input-sm" id="update_deduction_percentage" value="'+response['data'][i]['percentage']+'" required="required" /></div><div class="col-sm-2"><button class="btn btn-danger btn-sm remove_reduction"><i class="fa fa-trash-o"></i></button></div></div>'; }else{ html = '<div class="row" style="margin-top:10px;"><div class="col-sm-6"><input type="text" name="update_deduction_id[]" value="'+response['data'][i]['id']+'" hidden><input type="text" name="update_deduction_name[]" placeholder="Enter Deduction Name" class="form-control tip input-sm" id="update_deduction_name" value="'+response['data'][i]['name']+'" required="required" /></div><div class="col-sm-4"><input type="number" name="update_deduction_percentage[]" readonly placeholder="Enter Deduction Percentage" class="form-control tip input-sm" id="update_deduction_percentage" value="'+response['data'][i]['percentage']+'" required="required" /></div><div class="col-sm-2"></div></div>'; } // html = '<div class="row" style="margin-top:10px;"><div class="col-sm-6"><input type="text" name="update_deduction_id[]" value="'+response['data'][i]['id']+'" hidden><input type="text" name="update_deduction_name[]" placeholder="Enter Deduction Name" class="form-control tip input-sm" id="update_deduction_name" value="'+response['data'][i]['name']+'" required="required" /></div><div class="col-sm-4"><input type="number" name="update_deduction_percentage[]" placeholder="Enter Deduction Percentage" class="form-control tip input-sm" id="update_deduction_percentage" value="'+response['data'][i]['percentage']+'" required="required" /></div><div class="col-sm-2"><button class="btn btn-danger btn-sm remove_reduction"><i class="fa fa-trash-o"></i></button></div></div>'; $('#deduction_rows').append(html); } } } } }); } function showData(){ $('#loading-div').show(); $('#content-div').hide(); setTimeout(function() { $('#loading-div').hide(); $('#content-div').show('blind', {}, 500) }, 800); } }); </script> <script> $(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 type="text" name="create_allowance_name[]" placeholder="Enter Allowance Name" class="form-control tip input-sm" id="create_allowance_name" required="required" /></div><div class="col-sm-4"><input type="number" name="create_allowance_percentage[]" placeholder="Enter Allowance Percentage" class="form-control tip input-sm" id="create_allowance_percentage" required="required" /></div><div class="col-sm-2"><button class="btn btn-danger btn-sm remove_allowance"><i class="fa fa-trash-o"></i></button></div></div>'; $('#allowance_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 type="text" name="create_deduction_name[]" placeholder="Enter Deduction Name" class="form-control tip input-sm" id="update_deduction_name" required="required" /></div><div class="col-sm-4"><input type="number" name="create_deduction_percentage[]" placeholder="Enter Deduction Percentage" class="form-control tip input-sm" id="update_deduction_percentage" required="required" /></div><div class="col-sm-2"><button class="btn btn-danger btn-sm remove_reduction"><i class="fa fa-trash-o"></i></button></div></div>'; $('#deduction_rows').append(html); }); </script> <?php include "footer.php";?>