MMCT TEAM
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  ]

Current File : /home/u915722082/.nvm/../public_html/invoicebill/packaging.php
<?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['type']) && !empty($_POST['size']) && isset($_POST['quantity'])) {
        $type = trim($_POST['type']);
        $size = trim($_POST['size']);
        $quantity = intval($_POST['quantity']);
        
        $stmt = $conn->prepare("INSERT INTO packaging_materials (type, size, quantity) VALUES (?, ?, ?)");
        $stmt->bind_param("ssi", $type, $size, $quantity);
        
        if ($stmt->execute()) {
            $msg = '<div class="alert alert-success">Packaging material 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>Packaging Materials</h2>
    <?php echo $msg; ?>
    <!-- Form to Add Packaging Material -->
    <form method="POST" action="packaging.php">
        <div class="form-group">
            <label for="type">Packaging Type</label>
            <input type="text" class="form-control" id="type" name="type" placeholder="e.g., Plain Cover, Sack, Carton" required>
        </div>
        <div class="form-group">
            <label for="size">Size</label>
            <input type="text" class="form-control" id="size" name="size" placeholder="e.g., 200g, 500ml" required>
        </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 Packaging Material</button>
    </form>

    <hr>
    <h3>Existing Packaging Materials</h3>
    <table class="table table-bordered">
        <thead class="thead-dark">
            <tr>
                <th>Packaging Type</th>
                <th>Size</th>
                <th>Quantity</th>
            </tr>
        </thead>
        <tbody>
            <?php 
            $result = $conn->query("SELECT * FROM packaging_materials ORDER BY id DESC");
            while ($row = $result->fetch_assoc()):
            ?>
            <tr>
                <td><?php echo safe_output($row['type']); ?></td>
                <td><?php echo safe_output($row['size']); ?></td>
                <td><?php echo safe_output($row['quantity']); ?></td>
            </tr>
            <?php endwhile; ?>
        </tbody>
    </table>
</div>

<?php include 'templates/footer.php'; ?>

MMCT - 2023