CasperSecurity
<?php
session_start();
include '../../../web/connection/connectionv2.php';
include '../../../web/connection/con.php';
include '../../../web/connection/encryption.php';
$item_type = $_REQUEST['item_type'];
$item_typee = amebi_crypt($item_type,e);
$item_group_name = $_REQUEST['item_sgroups'];
$item_group_namee = amebi_crypt($item_group_name,e);
$brand_name = $_REQUEST['brand_name'];
$item_name = strtoupper($_REQUEST['item_name']);
$item_namee = amebi_crypt($item_name,e);
$item_unit = $_REQUEST['item_unit'];
$item_unite = amebi_crypt($item_unit,e);
$hsn_code = $_REQUEST['hsn_code'];
$hsn_codee = amebi_crypt($hsn_code,e);
$sgst_rate = $_REQUEST['sgst_rate'];
$sgst_ratee = amebi_crypt($sgst_rate,e);
$cgst_rate = $_REQUEST['cgst_rate'];
$cgst_ratee = amebi_crypt($cgst_rate,e);
$igst_rate = $_REQUEST['igst_rate'];
$igst_ratee = amebi_crypt($igst_rate,e);
$returnable = $_REQUEST['returnable'];
$returnablee = amebi_crypt($returnable,e);
$item_photo1 = $_FILES['item_photo1']['name'];
$photoPath = "../../../web/uploads/imguploads/";
$imgtype = pathinfo($item_photo1,PATHINFOEXTENSION);
$maxsize = 2097152;
$tempname = $_FILES['item_photo1']['tmp_name'];
$photoUpload = move_uploaded_file($tempname,$photoPath.$item_photo1);
$item_photo2 = $_FILES['item_photo2']['name'];
$photoPath = "../../../web/uploads/imguploads/";
$imgtype = pathinfo($item_photo2,PATHINFOEXTENSION);
$maxsize = 2097152;
$tempname = $_FILES['item_photo2']['tmp_name'];
$photoUpload = move_uploaded_file($tempname,$photoPath.$item_photo2);
$item_photo3 = $_FILES['item_photo3']['name'];
$photoPath = "../../../web/uploads/imguploads/";
$imgtype = pathinfo($item_photo3,PATHINFOEXTENSION);
$maxsize = 2097152;
$tempname = $_FILES['item_photo3']['tmp_name'];
$photoUpload = move_uploaded_file($tempname,$photoPath.$item_photo3);
$item_photo4 = $_FILES['item_photo4']['name'];
$photoPath = "../../../web/uploads/imguploads/";
$imgtype = pathinfo($item_photo4,PATHINFOEXTENSION);
$maxsize = 2097152;
$tempname = $_FILES['item_photo4']['tmp_name'];
$photoUpload = move_uploaded_file($tempname,$photoPath.$item_photo4);
$db_handle = new DBController();
$brands = $db_handle-> runQuery("SELECT * FROM canteen_brand WHERE brand_name = '$brand_name'");
foreach($brands as $brand){
$newInsert_brand_id = $brand['brand_id'];
}
date_default_timezone_set("Asia/Kolkata");
$date = date("Y-m-d H:i:s");
$active = 'yes';
$userId = $_SESSION['USER_ID'];
/*$db_handle = new DBController();
$igs = $db_handle-> runQuery("SELECT * FROM item_group WHERE item_group_name = '$item_group_name'");
foreach($igs as $ig){
$newinsertitem_group_id = $ig['item_group_id'];
}*/
$db_handle = new DBController();
$igs = $db_handle-> runQuery("SELECT * FROM canteen_item_subgroup WHERE item_subgroup_name = '$item_group_name'");
foreach($igs as $ig){
$newinsertitem_group_id = $ig['item_subgroup_id'];
}
/* $db_handle = new DBController();
$brand_numrows = $db_handle->numRows("SELECT * FROM brand WHERE brand_name = '$brand_name'");
if($brand_numrows >= '1'){
}else{
$db_handle = new DBController();
$newInsert_brand_id = $db_handle->tableinsert("INSERT INTO brand(brand_name,created_on,created_by,is_active)
VALUES ('$brand_name','$date','$userId','$active')");
}*/
$selecttry ="SELECT * FROM canteen_item_subgroup WHERE item_subgroup_name = '$item_group_name' 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 canteen_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_group_codez.'-'.$item_id;
}else{
$item_code = $item_codeyy;
}
$db_handle = new DBController();
$pur_nomrow = $db_handle-> numRows("SELECT * FROM canteen_item WHERE item_name = '$item_name'");
if($pur_nomrow == '0'){
$db_handle = new DBController();
$newInsert2 = $db_handle->tableinsert("INSERT INTO canteen_item(item_subgroup_id,item_type,item_code,item_name,item_unit,hsn_code,returnable,created_on,created_by,is_active)
VALUES ('$newinsertitem_group_id','$item_type','$item_code','$item_name','$item_unit','$hsn_code','$returnable','$date','$userId','$active')");
//$newI = $db_handle->tableinsert("INSERT INTO item_image(item_id,brand_id,Image1,Image2,Image3,Image4)
//VALUES ('$newInsert2','$newInsert_brand_id','$item_photo1','$item_photo2','$item_photo3','$item_photo4')");
$newInsert3 = $db_handle->tableinsert("INSERT INTO canteen_item_gst(item_id,effective_date,sgst_rate,cgst_rate,igst_rate,is_active)
VALUES ('$newInsert2','$date','$sgst_rate','$cgst_rate','$igst_rate','$active')");
} else{
$db_handle = new DBController();
$purinnvoices = $db_handle-> runQuery("SELECT * FROM canteen_item ORDER BY item_id DESC LIMIT 1");
$db_handle = new DBController();
foreach($purinnvoices as $purinnvoice){
$newInsert2 = $purinnvoice['item_id'];
}
//$newI = $db_handle->tableinsert("INSERT INTO item_image(item_id,brand_id,Image1,Image2,Image3,Image4)
//VALUES ('$newInsert2','$newInsert_brand_id','$item_photo1','$item_photo2','$item_photo3','$item_photo4')");
}
$itemidd = amebi_crypt($newInsert2,e);
header('location:../../../web/home/modules/stock/item/item_grid.php');
if($newInsert3 == TRUE){
$_SESSION['ERROR_MSG'] = "Item Inserted Successfully";
$_SESSION['MSG_ALRT'] = "TRUE";
header('location:../../../web/home/modules/university/Canteen/item/item_grid.php');
}else{
$_SESSION['ERROR_MSG'] = "Unsuccess";
$_SESSION['MSG_ALRT'] = "FALSE";
header('location:../../../web/home/modules/university/Canteen/item/item_grid.php');
}
?>