CasperSecurity
<?php
session_start();
include '../../../../web/connection/connection.php';
//financial transaction variables
$voucher_date = $_REQUEST['voucher_date'];
$voucher_particulars = $_REQUEST['voucher_particulars'];
$created_on = date("Y-m-d");
$created_by = $_SESSION['USER_ID'];
$is_active = 'yes';
//financial transaction ledger head variables
$ledger_head_id = $_REQUEST['ledger_head_id'];
$type = $_REQUEST['type'];
$amount = $_REQUEST['amount'];
//inserting data into financial transaction table
$db_handle = new DBController();
$newInsert = $db_handle->tableinsert("INSERT INTO financial_transactions(voucher_date,voucher_particulars,created_on,created_by,is_active)
VALUES ('$voucher_date','$voucher_particulars','$created_on','$created_by','$is_active')");
if($newInsert == TRUE){
echo 'Data Inserted in table 1 Successfully';
//if insertion is successful in financial transaction table then fetch a particular primary key needed
$db_handle = new DBController();
$select = $db_handle->runQuery("SELECT finance_transaction_id FROM financial_transactions WHERE voucher_date = '$voucher_date' ");
foreach ($select as $v){
$finance_transaction_id = $v['finance_transaction_id']; // unique primary key needed as a data for the nested table
}
//inserting data into financial transaction ledger head table
$db_handle = new DBController();
$newInsert2 = $db_handle->tableinsert("INSERT INTO financial_transaction_ledger_head(finance_transaction_id,ledger_head_id,type,amount)
VALUES ('$finance_transaction_id','$ledger_head_id','$type','$amount')");
if($newInsert2 == TRUE){
echo 'Data Inserted in table 2 Successfully';
}else{
echo 'Not Inserted 2' ;
}
}else{
echo 'Not Inserted 1' ;
}
?>