D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
insert_new_item.php
back
Copy
<?php error_reporting(0); ob_start(); session_start(); include 'config.php'; $item_id = date('Ymdhms'); $date = date('j F Y'); $code = ""; $reditect_url = $_SERVER['HTTP_REFERER']; $category = addslashes(stripslashes($_POST['category'])); $sourceId = addslashes(stripslashes($_POST['sourceId'])); $item_code = addslashes(stripslashes($_POST['item_code'])); $hsncode = addslashes(stripslashes($_POST['hsncode'])); $name = addslashes(stripslashes($_POST['name'])); $size = addslashes(stripslashes($_POST['size'])); $item_type = addslashes(stripslashes($_POST['item_type'])); $stock_high_threshold = addslashes(stripslashes($_POST['stock_high_threshold'])); $material = addslashes(stripslashes($_POST['material'])); $item_image = addslashes(stripslashes($_POST['item_image'])); $cost_variance_limit = addslashes(stripslashes($_POST['cost_variance_limit'])); $unit_of_measure = addslashes(stripslashes($_POST['unit_of_measure'])); $tax_inclusive = addslashes(stripslashes($_POST['tax_inclusive'])); $color = addslashes(stripslashes($_POST['color'])); $item_qty = addslashes(stripslashes($_POST['item_qty'])); $categoryName = ""; $sourceId = $_SESSION["source_id"]; $sqlGetCategoryName = "SELECT category FROM category WHERE id = '$category'"; $resultGetCategory = $conn->query($sqlGetCategoryName); if($resultGetCategory){ while($rowGetCategory = mysqli_fetch_assoc($resultGetCategory)){ $categoryName = $rowGetCategory["category"]; } } $file_name = ""; if(isset($_FILES["image"]) && $_FILES['image']['size'] != 0){ $file_name = $_FILES['image']['name']; $temp = explode(".", $_FILES["image"]["name"]); $extension = end($temp); $result1 = preg_replace("/[^a-zA-Z0-9]+/", "", $name); $file_name = $result1."_".date("Ymdhis").".".$extension; $file_tmp =$_FILES['image']['tmp_name']; move_uploaded_file($file_tmp,"inventory/".$file_name); } $check = mysqli_query($conn,"SELECT * FROM `inventory` where item_code='$item_code'"); $check_count = mysqli_num_rows($check); if($check_count == 0){ $sql = "INSERT INTO `inventory`(`item_code`, `hsn_code`, `name`, `size`, `unit_of_measure`, `item_type`, `stock_high_threshold`, `tax_inclusive`, `color`, `material`, `item_image`, `cost_variance_limit`, `category`, `item_qty`, `source_id`) VALUES ('$item_code','$hsncode','$name','$size','$unit_of_measure','$item_type','$stock_high_threshold','$tax_inclusive','$color','$material','$file_name','$cost_variance_limit','$categoryName','$item_qty','$sourceId')"; if ($conn->query($sql) === TRUE) { echo '<script>localStorage.setItem("ItemAdded", "true");</script>'; echo "<script>location.replace('$reditect_url')</script>"; } else { print_r(mysqli_error($conn)); } }else{ echo '<script>alert("Product Code Already In Your List")</script>'; echo "<script>location.replace('$reditect_url')</script>"; } ?>