D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
proc
/
self
/
root
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
edit_new_item.php
back
Copy
<?php ob_start(); session_start(); include 'config.php'; $login = $_SESSION['login_email']; if($login == ''){ echo '<script>location.replace("index.php")</script>'; } if(isset($_SESSION["source_id"])){ $source_id = $_SESSION['source_id']; } $id = $_GET['id']; $totalitem_qty=0; $total_invoice_item_qty=0; $sqlGetItem = "SELECT * FROM `inventory` where id = '$id'"; $resultGetItem = mysqli_query($conn,$sqlGetItem); if($resultGetItem){ if(mysqli_num_rows($resultGetItem)){ while($rowGetItem = mysqli_fetch_assoc($resultGetItem)){ $category = $rowGetItem['category']; $item_code = $rowGetItem['item_code']; $hsn_code = $rowGetItem['hsn_code']; $name = $rowGetItem['name']; $size = $rowGetItem['size']; $unit_of_measure = $rowGetItem['unit_of_measure']; $item_type_g = $rowGetItem['item_type']; $stock_high_threshold = $rowGetItem['stock_high_threshold']; $tax_inclusive = $rowGetItem['tax_inclusive']; $color = $rowGetItem['color']; $material = $rowGetItem['material']; $item_image = $rowGetItem['item_image']; $cost_variance_limit = $rowGetItem['cost_variance_limit']; $item_qty = $rowGetItem['item_qty']; $product_image = $rowGetItem['item_image']; $totalitem_qty=$totalitem_qty+$item_qty; } } } $remainStock=0; if(!empty($item_code)){ $sqld1 = "SELECT sum(`qty`) as `total_invoice_item_qty` FROM `invoice_item` where `item_code` = '$item_code' AND `marge_status` != 'yes' GROUP by `item_code`"; $resultd1 = mysqli_query($conn,$sqld1); $result_row = mysqli_fetch_array($resultd1); $total_invoice_item_qty = $result_row['total_invoice_item_qty']; }else{ $total_invoice_item_qty=0; } $remainStock=$totalitem_qty-$total_invoice_item_qty; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Invoice Management | Invoice</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" /> <meta content="Coderthemes" name="author" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- Font Awsome --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <!-- App favicon --> <link rel="shortcut icon" href="assets/images/favicon.png"> <!-- Pie Chart Css --> <link href="assets/pie charts/style.css" rel="stylesheet" type="text/css" /> <!-- App css --> <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="assets/css/icons.css" rel="stylesheet" type="text/css" /> <link href="assets/css/metismenu.min.css" rel="stylesheet" type="text/css" /> <link href="assets/css/style.css" rel="stylesheet" type="text/css" /> <script src="assets/js/modernizr.min.js"></script> <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.min.css'> <link href="plugins/sweet-alert2/sweetalert2.min.css" rel="stylesheet" type="text/css"> <link href="plugins/jquery-toastr/jquery.toast.min.css" rel="stylesheet" /> </head> <body> <!-- Begin page --> <div id="wrapper"> <!-- Top Bar Start --> <?php include 'top-header.php'; ?> <!-- Top Bar End --> <!-- ========== Left Sidebar Start ========== --> <?php include 'left-sidebar.php'; ?> <!-- Left Sidebar End --> <!-- ============================================================== --> <!-- Start right Content here --> <!-- ============================================================== --> <div class="content-page"> <!-- Start content --> <div class="content"> <div class="container-fluid"> <div class="row"> <div class="col-12"> <div class="page-title-box"> <h4 class="page-title float-left">Edit Inventory</h4> <ol class="breadcrumb float-right"> <li class="breadcrumb-item ">Inventory Manager</li> <li class="breadcrumb-item active">Edit Inventory</li> </ol> <div class="clearfix"></div> </div> </div> </div> <!-- end row --> <!-- end row --> <form action="update_new_item.php?id=<?php echo $id; ?>" method="post" role="form" id="frm" enctype="multipart/form-data"> <div class="card-box"> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="exampleInputEmail1">Category</label> <select class="form-control select" name="category" onchange="showUser(this.value)"> <option value="">Select Option</option> <?php $sql1 = "SELECT * FROM category WHERE source_id = '$source_id'"; $result1 = mysqli_query($conn, $sql1); while($row1 = mysqli_fetch_array($result1)){ ?> <option value="<?php echo $row1['id']; ?>" <?php if($category == $row1['category']){ echo "selected"; } ?> ><?php echo $row1['category'] ?></option> <?php } ?> </select> </div> </div> </div> </div> <div class="card-box"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label>Item Code</label> <input class="form-control" id="item_code" name="item_code" value="<?php echo $item_code ?>"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>HSN Code</label> <input class="form-control" name="hsncode" value="<?php echo $hsn_code ?>"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>Name</label> <input class="form-control" id="name" name="name" value="<?php echo $name ?>"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>Item Quantity</label> <span class="<?php if($remainStock >0){ echo "text-success";}else{ echo "text-danger";}?>" style="float: right;font-weight: 600;">In Stock <span class="infigure"><?php echo $remainStock;?></span></span> <input type="hidden" class="form-control" id="old_item_qty" name="old_item_qty" value="<?php echo $item_qty ?>"> <input type="number" class="form-control" name="item_qty" id="item_qty" value="" required> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>Size</label> <input class="form-control" name="size" value="<?php echo $size ?>"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>Unit Of Measure</label> <select name="unit_of_measure" class="form-control select22"> <option>--select units--</option> <option value="Yard" <?php if($unit_of_measure == 'Yard'){ echo "selected"; } ?>>Yard</option> <option value="Box" <?php if($unit_of_measure == 'Box'){ echo "selected"; } ?>>Box</option> <option value="Cms" <?php if($unit_of_measure == 'Cms'){ echo "selected"; } ?>>Cms</option> <option value="Gross" <?php if($unit_of_measure == 'Gross'){ echo "selected"; } ?>>Gross</option> <option value="Kg" <?php if($unit_of_measure == 'Kg'){ echo "selected"; } ?>>Kg</option> <option value="Mtr" <?php if($unit_of_measure == 'Mtr'){ echo "selected"; } ?>>Mtr</option> <option value="Mile Meter" <?php if($unit_of_measure == 'Mile Meter'){ echo "selected"; } ?>>Mile Meter</option> <option value="Nothing" <?php if($unit_of_measure == 'Nothing'){ echo "selected"; } ?>>Nothing</option> <option value="N/A" <?php if($unit_of_measure == 'N/A'){ echo "selected"; } ?>>N/A</option> <option value="Nos" <?php if($unit_of_measure == 'Nos'){ echo "selected"; } ?>>Nos</option> <option value="Pairs" <?php if($unit_of_measure == 'Pairs'){ echo "selected"; } ?>>Pairs</option> <option value="Pcs" <?php if($unit_of_measure == 'Pcs'){ echo "selected"; } ?>>Pcs</option> <option value="Sets" <?php if($unit_of_measure == 'Sets'){ echo "selected"; } ?>>Sets</option> <option value="Sheet" <?php if($unit_of_measure == 'Sheet'){ echo "selected"; } ?>>Sheet</option> <option value="Soft" <?php if($unit_of_measure == 'Soft'){ echo "selected"; } ?>>Soft</option> <option value="Styles" <?php if($unit_of_measure == 'Styles'){ echo "selected"; } ?>>Styles</option> <option value="mm" <?php if($unit_of_measure == 'mm'){ echo "selected"; } ?>>mm</option> <option value="cm" <?php if($unit_of_measure == 'cm'){ echo "selected"; } ?>>cm</option> <option value="dm" <?php if($unit_of_measure == 'dm'){ echo "selected"; } ?>>dm</option> <option value="km" <?php if($unit_of_measure == 'km'){ echo "selected"; } ?>>km</option> <option value="other">Other</option> </select> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>Stock High Threshold</label> <input class="form-control" name="stock_high_threshold" value="<?php echo $stock_high_threshold ?>"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>Tax Inclusive</label> <select class="form-control" name="tax_inclusive"> <option>--select type--</option> <option>No</option> </select> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>Color</label> <input class="form-control" name="color" value="<?php echo $color ?>"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>Material</label> <input class="form-control" name="material" value="<?php echo $material ?>"> </div> </div> <div class="col-md-6"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label>Item Image</label> <input type="file" class="form-control" name="item_image"> </div> </div> <div class="col-md-6"> <label>Current Image</label><br> <img src="inventory/<?php echo $product_image; ?>" width="50"> <input type="hidden" name="old_image" value="<?php echo $product_image ?>"> </div> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>Cost Variance Limit(%)</label> <input class="form-control" name="cost_variance_limit" value="<?php echo $cost_variance_limit ?>"> </div> </div> </div> <button type="button" id="btn" class="btn btn-purple waves-effect waves-light w-100">Update</button> </div> </form> </div> </div> <!-- container --> </div> <!-- content --> <?php include 'copyrignt.php' ?> </div> <div id="myModal" class="modal fade" role="dialog" style="z-index:999999"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> </div> <div class="modal-body"> <form action="" method="post" role="form" id="categoryForm"> <input type="hidden" name="sourceId" value="<?php echo $source_id; ?>"> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="taxableExpense"> <input type="radio" value="Product" checked="checked" name="categoryFor" id="taxableExpense"> Product </label> <label for="taxableExpense1"> <input type="radio" value="Service" name="categoryFor" id="taxableExpense1"> Service </label> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="exampleInputEmail1">Category</label> <input type="text" class="form-control" name="categoryName" id="categoryName" placeholder="Enter category"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="exampleInputEmail1">Tax</label> <input type="text" class="form-control" name="categoryTax" id = "categoryTax" placeholder="Enter tax "> </div> </div> <button type="button" id="submitCategory" class="btn btn-purple waves-effect waves-light">Submit</button> </div> </form> </div> </div> </div> </div> <!-- END wrapper --> <!-- Chart Js --> <!-- <script src='https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.js'></script> --> <!-- jQuery --> <script src="assets/js/jquery.min.js"></script> <script src="assets/js/popper.min.js"></script><!-- Popper for Bootstrap --> <script src="assets/js/bootstrap.min.js"></script> <script src="assets/js/metisMenu.min.js"></script> <script src="assets/js/waves.js"></script> <script src="assets/js/jquery.slimscroll.js"></script> <!-- Dashboard init --> <!-- <script src="assets/pages/jquery.dashboard.js"></script> --> <!-- App js --> <script src="assets/js/jquery.core.js"></script> <script src="assets/js/jquery.app.js"></script> <!-- Chart Js --> <!-- <!-- <script src="assets/pie charts/script.js"></script> --> --> <script src='https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js'></script> <script src="plugins/sweet-alert2/sweetalert2.min.js"></script> <script src="plugins/jquery-toastr/jquery.toast.min.js" type="text/javascript"></script> <script> $(document).ready(function () { var flg = 0; $('.select').select2().on("select2:open", function () { flg++; if (flg == 1) { $(".select2-results").append("<div onclick='openModal()' class='select2-results__option' style='color:blue;cursor:pointer'> +Add New</div>"); } }); }); $(function () { $(".select22") .on('select2:close', function() { var el = $(this); if(el.val()==="other") { var newval = prompt("Enter other value you want: "); if(newval !== null) { el.append('<option>'+newval+'</option>') .val(newval); } } }); }); function selectOption() { $('.select22').select2(); } $(document).ready(function() { forSelect(); }); function forSelect() { selectOption(); $('#add').click(function() { var text = $('#text').html(); $('#demo').append(text); $('#demo .select').select2(); $('#demo .select').last().next().next().remove(); }); } function openModal(){ $("#myModal").modal("toggle"); } $(document).ready(function(){ if (localStorage.getItem("CategoryAdded") == "true") { successMessage("Category Successfully Added."); localStorage.setItem("CategoryAdded", "false"); } }); $("#submitCategory").click(function(){ if($("#categoryName").val() == ""){ errorToast("Please Enter Category Name"); } else{ $.ajax({ url : "PHP/response.php", data : $("#categoryForm").serialize()+"&action=AddCategory", method : "POST", async : false, success : function(response){ if(response == "SUCCESS"){ localStorage.setItem("CategoryAdded", "true"); location.reload(); } else{ errorMessage("Category could not be added"); } }, error : function(error){ errorMessage("Category could not be added"); } }) } }); function errorToast(msg){ $.toast({ heading: 'Error!', text: msg, position: 'top-right', loaderBg: '#bf441d', icon: 'error', hideAfter: 3000, stack: 1 }); } function successMessage(msg){ swal({ title: 'Success!', text: msg, type: 'success', confirmButtonColor: '#4fa7f3' }); } function errorMessage(msg){ swal({ title: 'Error!', text: msg, type: 'error', confirmButtonColor: '#4fa7f3' }); } $("#btn").click(function(){ if($("#category").val() == ""){ errorToast("Please Select Category"); } else if($("#item_name").val() == ""){ errorToast("Please Enter Item Name"); } else if($("#selling_price").val() == ""){ errorToast("Please Enter Price"); } else if($("#quantity").val() == ""){ errorToast("Please Enter quantity"); } else{ $("#frm").submit(); } }); function showUser(str) { $.ajax({ url : "PHP/response.php", data : "action=getCategoryById&categoryId="+str, method : "POST", async : false, success : function(response){ var str = JSON.parse(response); var tax = str.tax; var categoryFor = str.category_for; $("#tax").val(tax); $("#categoryfor").val(categoryFor); if(categoryFor.trim() === "Product"){ $("#divHSNCode").css({"display": "block"}); $("#divSACCode").css({"display": "none"}); $("#divQuantity").css({"display" : "block"}); } else { $("#divHSNCode").css({"display": "none"}); $("#divSACCode").css({"display": "block"}); $("#divQuantity").css({"display" : "none"}); $("#quantity").val("0"); } }, error:function(){} }); } </script> </body> </html>