CasperSecurity
<?php
session_start();
include '../../../../web/connection/connection.php';
// add new vendor variables
$vendor_id = $_REQUEST['vendor_id'];
$organisation_unit_id = $_REQUEST['organisation_unit_id'];
$vendor_type = $_REQUEST['vendor_type'];
$vendor_code = $_REQUEST['vendor_code'];
$vendor_name = $_REQUEST['vendor_name'];
$vendor_logo = $_REQUEST['vendor_logo'];
$vendor_address = $_REQUEST['vendor_address'];
$vendor_tele_phone = $_REQUEST['vendor_tele_phone'];
$vendor_fax = $_REQUEST['vendor_fax'];
$vendor_mail = $_REQUEST['vendor_mail'];
$vendor_contact_person = $_REQUEST['vendor_contact_person'];
$vendor_contact_person_telephone = $_REQUEST['vendor_contact_person_telephone'];
$vendor_contact_person_mobile = $_REQUEST['vendor_contact_person_mobile'];
$vendor_contact_person_mail = $_REQUEST['vendor_contact_person_mail'];
$inter_state = $_REQUEST['inter_state'];
$created_on = date('Y-m-d');
$created_by = $_SESSION['USER_ID'];
$is_active = 'yes';
// add new vendor type variables
$vendor_type_id = $_REQUEST['vendor_type_id'];
$vendor_type_name = $_REQUEST['vendor_type_name'];
// inserting values to vendor table
$db_handle = new DBController();
$newInsert = $db_handle->tableinsert("INSERT INTO vendor(vendor_id,organisation_unit_id,vendor_type,vendor_code,vendor_name,vendor_logo,vendor_address,vendor_tele_phone,
vendor_fax,vendor_mail,vendor_contact_person,vendor_contact_person_telephone,vendor_contact_person_mobile,vendor_contact_person_mail,inter_state,created_on,created_by,is_active)
VALUES('$vendor_id','$organisation_unit_id','$vendor_type','$vendor_code','$vendor_name','$vendor_logo','$vendor_address','$vendor_tele_phone','$vendor_fax','$vendor_mail',
'$vendor_contact_person','$vendor_contact_person_telephone','$vendor_contact_person_mobile','$vendor_contact_person_mail','$inter_state','$created_on','$created_by','$is_active')");
if($newInsert == TRUE){
echo 'Data Inserted Successfully in table 1';
//if insertion is successful in vendor table then fetch a particular primary key needed
$db_handle = new DBController();
$select = $db_handle->runQuery("SELECT vendor_id FROM vendor WHERE vendor_name = '$vendor_name' ");
foreach ($select as $v){
$vendor_id = $v['vendor_id']; // unique primary key needed as a data for the nested table
}
// inserting data into vendor type table
$db_handle = new DBController();
$newInsert2 = $db_handle->tableinsert("INSERT INTO vendor_type(vendor_type_id,vendor_type_name)
VALUES('$vendor_type_id','$vendor_type_name')");
if($newInsert2 == TRUE){
echo 'Data Inserted Successfully in table 2';
}else{
echo 'Not Inserted in 2' ;
}
}else{
echo 'Not Inserted in 1' ;
}
?>