D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
update_new_item.php
back
Copy
<?php ob_start(); session_start(); include 'config.php'; $item_id = date('Ymdhms'); $date = date('j F Y'); $code = ""; $id = $_GET['id']; $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'])); $old_item_qty = addslashes(stripslashes($_POST['old_item_qty'])); $item_qty=$item_qty+$old_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["item_image"]) && $_FILES['item_image']['size'] != 0){ $file_name = $_FILES['item_image']['name']; $temp = explode(".", $_FILES["item_image"]["name"]); $extension = end($temp); $result1 = preg_replace("/[^a-zA-Z0-9]+/", "", $name); $file_name = $result1."_".date("Ymdhis").".".$extension; $file_tmp =$_FILES['item_image']['tmp_name']; move_uploaded_file($file_tmp,"inventory/".$file_name); } // Old Image Name $old_image = $_POST['old_image']; if($file_name == ''){ $a = $old_image; }else{ $a = $file_name ; } $sql = "UPDATE `inventory` SET `item_code`='$item_code',`hsn_code`='$hsncode',`name`='$name',`size`='$size',`unit_of_measure`='$unit_of_measure',`item_type`='$item_type',`stock_high_threshold`='$stock_high_threshold',`tax_inclusive`='$tax_inclusive',`color`='$color',`material`='$material',`item_image`='$a',`cost_variance_limit`='$cost_variance_limit',`category`='$category',`item_qty`='$item_qty' WHERE id = '$id'"; if ($conn->query($sql) === TRUE) { echo '<script>localStorage.setItem("ItemUpdated", "true");</script>'; echo '<script>location.replace("inventory.php");</script>' ; } ?>