CasperSecurity
<?php
session_start();
include '../../../../web/connection/connection.php';
//account group variables
$type = $_REQUEST['type'];
$account_group_code = $_REQUEST['account_group_code'];
$account_group_name = $_REQUEST['account_group_name'];
$created_on = date("Y-m-d");
$created_by = $_SESSION['USER_ID'];
$is_active = 'yes';
//account sub group variables
$account_sub_group_code = $_REQUEST['account_sub_group_code'];
$account_sub_group_name = $_REQUEST['account_sub_group_name'];
$created_on = date("Y-m-d");
$created_by = $_SESSION['USER_ID'];
$is_active = 'yes';
//ledger head variables
$ledger_head = $_REQUEST['ledger_head'];
$ledger_head_name = $_REQUEST['ledger_head_name'];
$ledger_type = $_REQUEST['ledger_type'];
$created_on = date("Y-m-d");
$created_by = $_SESSION['USER_ID'];
$is_active = 'yes';
//inserting data into account group table
$db_handle = new DBController();
$newInsert = $db_handle->tableinsert("INSERT INTO account_group(type,account_group_code,account_group_name,created_on,created_by,is_active)
VALUES ('$type','$account_group_code','$account_group_name','$created_on','$created_by','$is_active')");
if($newInsert == TRUE){
echo 'Data Inserted in table 1 Successfully';
//if insertion is successful in account group table then fetch a particular primary key needed
$db_handle = new DBController();
$select = $db_handle->runQuery("SELECT account_group_id FROM account_group WHERE type = '$type' ");
foreach ($select as $v){
$account_group_id = $v['account_group_id']; // unique primary key needed as a data for the nested table
}
//inserting data into account sub group table
$db_handle = new DBController();
$newInsert2 = $db_handle->tableinsert("INSERT INTO account_sub_group(account_group_id,account_sub_group_code,account_sub_group_name,created_on,created_by,is_active)
VALUES ('$account_group_id','$account_sub_group_code','$account_sub_group_name','$created_on','$created_by','$is_active')");
if($newInsert2 == TRUE){
echo 'Data Inserted in table 2 Successfully';
//if insertion is successful in account sub group table then fetch a particular primary key needed
$db_handle = new DBController();
$select = $db_handle->runQuery("SELECT account_sub_group_id FROM account_sub_group WHERE ledger_head_name = '$ledger_head_name' ");
foreach ($select as $v){
$account_sub_group_id = $v['account_sub_group_id']; // unique primary key needed as a data for the nested table
}
//inserting data into ledger head table
$db_handle = new DBController();
$newInsert3 = $db_handle->tableinsert("INSERT INTO ledger_head(account_sub_group_id,ledger_head,ledger_head_name,ledger_type,created_on,created_by,is_active)
VALUES ('$account_sub_roup_id','$ledger_head','$ledger_head_name','$ledger_type','$created_on','$created_by','$is_active')");
if($newInsert3 == TRUE){
echo 'Data Inserted in table 3 Successfully';
}else{
echo 'Not Inserted 3' ;
}
}else{
echo 'Not Inserted 2' ;
}
}else{
echo 'Not Inserted 1' ;
}
?>