Файловый менеджер - Редактировать - /home/d46091/invoice.ecogenix.in/purchase_order.php
Назад
<?php require_once('includes/connection.php'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { // echo '<pre>'; // print_r($_POST); // die(); // Sanitize and assign form inputs $company_id = mysqli_real_escape_string($conn, $_POST['company_id']); $customer_id = mysqli_real_escape_string($conn, $_POST['customer_id']); $po_no = mysqli_real_escape_string($conn, $_POST['po_no']); $po_date = mysqli_real_escape_string($conn, $_POST['po_date']); $rate = mysqli_real_escape_string($conn, $_POST['rate']); $po_quantity = mysqli_real_escape_string($conn, $_POST['po_quantity']); $po_quantity_left = mysqli_real_escape_string($conn, $_POST['po_quantity_left']); $created_at = date('Y-m-d H:i:s'); $stmt = $conn->prepare(" INSERT INTO `purchase_order_master` (`company_name`, `customer_name`, `po_no`, `po_date`, `rate`, `po_quantity`, `po_quantity_left`, `created_at`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) "); if ($stmt) { $stmt->bind_param( "ssssssss", $company_id, $customer_id, $po_no, $po_date, $rate, $po_quantity, $po_quantity_left, $created_at ); if ($stmt->execute()) { echo "<script> alert('Purchase Order added successfully!'); window.location.href = 'purchase_order.php'; </script>"; } else { echo "Error executing query: " . $stmt->error; } $stmt->close(); } else { echo "Failed to prepare statement: " . $conn->error; } $conn->close(); } require_once('includes/header.php'); ?> <!-- Content --> <div class="content"> <nav class="navbar navbar-expand-lg navbar-light bg-light mb-4"> <div class="container-fluid"> <button id="sidebarToggle" class="btn btn-outline-secondary d-md-none mr-auto"> <span class="navbar-toggler-icon"></span> </button> <a class="navbar-brand d-md-none" href="#">ECOGENIX</a> <div class="d-flex"> <!-- <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search"> --> <!-- <button class="btn btn-outline-success" type="submit">Search</button> --> </div> </div> </nav> <div class="container-fluid"> <div class="row"> <div class="col-12"> <h2 class="mb-4">Purchase Order Dashboard</h2> </div> </div> <!-- <div class="row mb-4"> <div class="col-md-3 col-sm-6 mb-3"> <div class="card text-white bg-primary"> <div class="card-body"> <h5 class="card-title">Total Products</h5> <h3 class="card-text">-</h3> </div> </div> </div> <div class="col-md-3 col-sm-6 mb-3"> <div class="card text-white bg-success"> <div class="card-body"> <h5 class="card-title">Active Products</h5> <h3 class="card-text">-</h3> </div> </div> </div> <div class="col-md-3 col-sm-6 mb-3"> <div class="card text-white bg-warning"> <div class="card-body"> <h5 class="card-title">Low Stock</h5> <h3 class="card-text">-</h3> </div> </div> </div> <div class="col-md-3 col-sm-6 mb-3"> <div class="card text-white bg-danger"> <div class="card-body"> <h5 class="card-title">Out of Stock</h5> <h3 class="card-text">-</h3> </div> </div> </div> </div> --> <div class="row"> <div class="col-12"> <div class="card"> <div class="card-header d-flex justify-content-between align-items-center"> <span>Inventory</span> <div> <!-- <button class="btn btn-sm btn-outline-primary">Export</button> --> <button class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#addItemModal">Add New</button> </div> </div> <div class="card-body"> <div class="table-responsive"> <table class="table table-striped table-hover table-bordered"> <thead> <tr> <th>ID</th> <th>Our Company</th> <th>Customer</th> <th>PO No.</th> <th>Date</th> <th>Rate</th> <th>P.O. Quantity</th> <th>P.O. Quantity Dispatched</th> <th>P.O. Quantity Left</th> <th>Actions</th> </tr> </thead> <tbody> <?php $query = "SELECT * FROM `purchase_order_master` ORDER BY `id` DESC"; $result = $conn->query($query); $index = 1; // Initialize row index if ($result && $result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo "<tr> <td>{$index}</td> <td>" . htmlspecialchars($row['company_name']) . "</td> <td>" . htmlspecialchars($row['customer_name']) . "</td> <td>" . htmlspecialchars($row['po_no']) . "</td> <td>" . htmlspecialchars($row['po_date']) . "</td> <td>" . htmlspecialchars($row['rate']) . "</td> <td>" . htmlspecialchars($row['po_quantity']) . "</td> <td>" . htmlspecialchars($row['po_quantity_dispatched'] ?? '0') . "</td> <td>" . htmlspecialchars($row['po_quantity_left']) . "</td> <td> <a href='purchase_order_edit.php?id={$row['id']}' class='btn btn-sm btn-warning'> <i class='fa-solid fa-pen'></i> </a> </td> </tr>"; $index++; // Increment index } } else { echo '<tr><td colspan="10" class="text-center">No records found.</td></tr>'; } ?> </tbody> </table> </div> <!-- <nav> <ul class="pagination justify-content-center"> <li class="page-item disabled"> <a class="page-link" href="#" tabindex="-1">Previous</a> </li> <li class="page-item active"><a class="page-link" href="#">1</a></li> <li class="page-item"><a class="page-link" href="#">2</a></li> <li class="page-item"><a class="page-link" href="#">3</a></li> <li class="page-item"> <a class="page-link" href="#">Next</a> </li> </ul> </nav> --> </div> </div> </div> </div> </div> </div> <!-- Add Item Modal --> <div class="modal fade" id="addItemModal" tabindex="-1" aria-labelledby="addItemModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <form action="" method="POST"> <!-- Replace with your actual form handler --> <div class="modal-header"> <h5 class="modal-title" id="addItemModalLabel">Add Purchase Order No</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <!-- Item Name --> <div class="mb-3"> <label for="company_id">Our Company Name</label> <select class="form-control" id="company_id" name="company_id" required> <option value="" selected disabled>--Select Company Name--</option> <?php $vendor_query = "SELECT `id`, `c_name` FROM `company_master`"; $result = $conn->query($vendor_query); if ($result && $result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo "<option value='" . htmlspecialchars($row['c_name']) . "'>" . htmlspecialchars($row['c_name']) . "</option>"; } } ?> </select> </div> <div class="mb-3"> <label for="customer_id">Customer Name:</label> <select class="form-control" id="customer_id" name="customer_id"> <option value="" selected disabled>--Select Customer Name--</option> <?php $vendor_query = "SELECT `id`, `cus_name` FROM `customer_master`"; $result = $conn->query($vendor_query); if ($result && $result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo "<option value='" . htmlspecialchars($row['cus_name']) . "'>" . htmlspecialchars($row['cus_name']) . "</option>"; } } ?> </select> </div> <div class="mb-3"> <label for="po_no" class="form-label">Number</label> <input type="text" class="form-control" id="po_no" name="po_no" required> </div> <div class="mb-3"> <label for="po_date" class="form-label">Date</label> <input type="date" class="form-control" id="po_date" name="po_date" required> </div> <!-- Unit --> <div class="mb-3"> <label for="rate" class="form-label">Rate</label> <input type="text" class="form-control" id="rate" name="rate" required> </div> <div class="mb-3"> <label for="po_quantity" class="form-label">P.O Quantity</label> <input type="text" class="form-control" id="po_quantity" name="po_quantity" required> </div> <!-- <div class="mb-3"> --> <!-- <label for="po_quantity_left" class="form-label">P.O Quantity Left</label> --> <input type="hidden" class="form-control" id="po_quantity_left" name="po_quantity_left" required> <!-- </div> --> </div> <div class="modal-footer"> <button type="submit" class="btn btn-success">Save Item</button> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> </div> </form> </div> </div> </div> <?php require_once('includes/footer.php'); ?> <script> document.addEventListener("DOMContentLoaded", function() { const poQty = document.getElementById("po_quantity"); const poQtyLeft = document.getElementById("po_quantity_left"); poQty.addEventListener("input", function() { poQtyLeft.value = this.value; }); }); </script>
| ver. 1.4 |
Github
|
.
| PHP 8.1.32 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка