CasperSecurity
<?php
session_start();
include '../../../../web/connection/connection.php';
// leave credit variables
$month_year = $_REQUEST['month_year'];
$leave_rule_id = $_REQUEST['leave_rule_id'];
$created_on = date("Y-m-d");
$created_by = $_REQUEST['created_by'];
$Is_active = $_REQUEST['Is_active'];
// leave credit days variables
$leave_credit_id = $_REQUEST['leave_credit_id'];
$employee_id = $_REQUEST['employee_id'];
$leave_credit_days = $_REQUEST['leave_credit_days'];
// inserting data into leave credit table
$db_handle = new DBController();
$newInsert = $db_handle->tableinsert("INSERT INTO leave_credit(month_year,leave_rule_id,created_on,created_by,Is_active)
VALUES('$month_year','$leave_rule_id','$created_on','$created_by','Is_active')");
if($newInsert == TRUE){
echo 'Data Inserted Successfully in table 1';
//if insertion is successful in leave credit table then fetch a particular primary key needed
$db_handle = new DBController();
$select = $db_handle->runQuery("SELECT leave_credit_id FROM leave_credit WHERE employee_id = '$employee_id' ");
foreach ($select as $v){
$leave_credit_id = $v['leave_credit_id']; // unique primary key needed as a data for the nested table
}
// inserting data into leave credit days
$db_handle = new DBController();
$newInsert2 = $db_handle->tableinsert("INSERT INTO leave_credit_days(leave_credit_id,employee_id,leave_credit_days)
VALUES('$leave_credit_id','$employee_id','$leave_credit_days')");
if($newInsert2 == TRUE){
echo 'Data Inserted Successfully in table 2';
}else{
echo 'Not Inserted in table 2' ;
}
}else{
echo 'Not Inserted in 1' ;
}
?>