CasperSecurity
<?php
session_start();
include '../../../../web/connection/connection.php';
// salary structure variables
$employee_id = $_REQUEST['employee_id'];
$effective_month = $_REQUEST['effective_month'];
$effective_year = $_REQUEST['effective_year'];
$gross_salary = $_REQUEST['gross_salary'];
$approve_status = $_REQUEST['approve_status'];
$created_on = date("Y-m-d");
$created_by = $_SESSION['USER_ID'];
$is_active = 'yes';
// salary structure figure variables
$employee_salary_structure_id = $_REQUEST['employee_salary_structure_id'];
$salary_type_id = $_REQUEST['salary_type_id'];
$allowed_percentage = $_REQUEST['allowed_percentage'];
$earning_figure = $_REQUEST['earning_figure'];
$deduction_figure = $_REQUEST['deduction_figure'];
$attendance_dependents = $_REQUEST['attendance_dependents'];
// inserting data into employee_salary_structure table
$db_handle = new DBController();
$newInsert = $db_handle->tableinsert("INSERT INTO employee_salary_structure (employee_id,effective_month,effective_year,gross_salary,
approve_status,created_on,created_by,is_active)
VALUES('$employee_id','$effective_month','$effective_year','$gross_salary','$approve_status','$created_on','$created_by','$is_active')");
if($newInsert == TRUE){
echo 'Data Inserted Successfully in 1';
}else{
echo 'Not Inserted in 1' ;
}
//if insertion is successful in employee_salary_structure table then fetch a particular primary key needed
$db_handle = new DBController();
$select = $db_handle->runQuery("SELECT employee_salary_structure_id FROM branchs WHERE employee_id = '$employee_id' ");
foreach ($select as $v){
$employee_salary_structure_id = $v['employee_salary_structure_id']; // unique primary key needed as a data for the nested table
}
// inserting data into salary structure figure table
$db_handle = new DBController();
$newInsert2 = $db_handle->tableinsert("INSERT INTO employee_salary_structure_figure (employee_salary_structure_id,salary_type_id,allowed_percentage,earning_figure,
deduction_figure,attendance_dependents)
VALUES('$employee_salary_structure_id','$salary_type_id','$allowed_percentage','$earning_figure','$deduction_figure','$attendance_dependents')");
if($newInsert2 == TRUE){
echo 'Data Inserted Successfully in table 2';
}else{
echo 'Not Inserted in 2' ;
}
?>