CasperSecurity
<?php
session_start();
include '../../../web/connection/connection.php';
include '../../../web/connection/con.php';
include '../../../web/connection/functions/encryption.php';
$item_type = $_REQUEST['item_type'];
$item_group_name = $_REQUEST['item_groups'];
$purchase_order_date = $_REQUEST['purchase_order_date'];
$sup_name = $_REQUEST['sup_name'];
$item_name = $_REQUEST['item_name'];
$item_unit = $_REQUEST['item_unit'];
$hsn_code = $_REQUEST['hsn_code'];
$cgst_rate = $_REQUEST['cgst_rate'];
$sgst_rate = $_REQUEST['sgst_rate'];
$igst_rate = $_REQUEST['igst_rate'];
$returnable = $_REQUEST['returnable'];
$purchase_idzy = $_REQUEST['purchase_idzy'];
$date = date("Y-m-d");
$active = 'yes';
$userId = $_SESSION['USER_ID'];
if(!empty($hsn_code)){
$selecttry ="SELECT * FROM item_group ORDER BY item_group_id DESC";
$querytry=mysqli_query($con, $selecttry);
$resulttry=mysqli_fetch_assoc($querytry);
//$item_group_code = $resulttry['item_group_code'];
$item_group_idk = $resulttry['item_group_id']+1;
$zeros = 0;
$item_group_codez = $zeros.''.$item_group_idk;
$selecttr="SELECT * FROM item ORDER BY item_id DESC";
$querytr=mysqli_query($con, $selecttr);
$resulttr=mysqli_fetch_assoc($querytr);
$item_id = $resulttr['item_id']+1;
$zero = 0;
$item_codeyy = $item_group_codez.'-'.$zero.''.$zero.''.$zero.''.$zero.''.$item_id;
if(($item_id >= '10') && ($item_id < '100')){
$item_code = $item_group_codez.'-'.$zero.''.$zero.''.$zero.''.$item_id;
}elseif(($item_id >= '100')&&($item_id < '1000')){
$item_code = $item_group_codez.'-'.$zero.''.$zero.''.$item_id;
}elseif($item_id >= '1000'){
$item_code = $item_id;
}else{
$item_code = $item_codeyy;
}
$db_handle = new DBController();
$item_groups = $db_handle-> runQuery("SELECT * FROM item_group WHERE item_group_name = '$item_group_name'");
foreach($item_groups as $item_group){
$newInsert_item_group_id = $item_group['item_group_id'];
}
$db_handle = new DBController();
$itemgrp_numrows = $db_handle->numRows("SELECT * FROM item_group WHERE item_group_name = '$item_group_name'");
if($itemgrp_numrows >= '1'){
}else{
$db_handle = new DBController();
$newInsert_item_group_id = $db_handle->tableinsert("INSERT INTO item_group(item_group_code,item_group_name,created_on,created_by,is_active)
VALUES ('$item_group_codez','$item_group_name','$date','$userId','$active')");
}
$db_handle = new DBController();
$newInsert2 = $db_handle->tableinsert("INSERT INTO item(item_group_id,item_type,item_code,item_name,item_unit,hsn_code,returnable,created_on,created_by,is_active)
VALUES ('$newInsert_item_group_id','$item_type','$item_code','$item_name','$item_unit','$hsn_code','$returnable','$date','$userId','$active')");
$newInsert3 = $db_handle->tableinsert("INSERT INTO item_gst(item_id,effective_date,sgst_rate,cgst_rate,igst_rate,is_active)
VALUES ('$newInsert2','$date','$sgst_rate','$cgst_rate','$igst_rate','$active')");
$item_typea =amebi_crypt($item_type,e);
$item_namea =amebi_crypt($item_name,e);
/*$purchase_order_datea =amebi_crypt($purchase_order_date,e);
$sup_namea =amebi_crypt($sup_name,e);*/
if($newInsert3 == TRUE){
$_SESSION['ERROR_MSG'] = "Success";
$_SESSION['MSG_ALRT'] = "TRUE";
header('location:../../../web/home/modules/stock/purchase_order/additem.php?item_type='.$item_typea.'&itemname='.$item_namea.'&purchase_order_date='.$purchase_order_date.'&myInput='.$sup_name);
}else{
$_SESSION['ERROR_MSG'] = "Unsuccess";
$_SESSION['MSG_ALRT'] = "FALSE";
header('location:../../../web/home/modules/stock/purchase_order/additem.php?item_type='.$item_typea.'&itemname='.$item_namea.'&purchase_order_date='.$purchase_order_date.'&myInput='.$sup_name);
}
}
?>