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/process_order.php
<?php
require_once 'includes/db.php';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Retrieve form values
    $order_date = $_POST['order_date'];
    $order_type = $_POST['order_type']; // 'Invoice' or 'SlipOnly'
    $is_accounted = isset($_POST['is_accounted']) ? 1 : 0;
    $product_id = $_POST['product_id'];
    $quantity = $_POST['quantity'];
    $packaging_type = $_POST['packaging_type'];

    // Insert into orders table
    $invoice_number = null;
    $status = 'Pending';
    if ($order_type == 'Invoice' && $is_accounted) {
        // Generate a unique invoice number (here, using a simple timestamp-based method)
        $invoice_number = "INV" . time();
        $status = 'Accounted';
    } elseif ($order_type == 'Invoice' && !$is_accounted) {
        $status = 'Unaccounted';
    }
    $stmt = $conn->prepare("INSERT INTO orders (order_date, order_type, invoice_number, is_accounted, status) VALUES (?, ?, ?, ?, ?)");
    $stmt->bind_param("sssis", $order_date, $order_type, $invoice_number, $is_accounted, $status);
    $stmt->execute();
    $order_id = $stmt->insert_id;
    $stmt->close();

    // Insert order item (for simplicity, one item per order)
    $stmt = $conn->prepare("INSERT INTO order_items (order_id, product_id, quantity, packaging_type) VALUES (?, ?, ?, ?)");
    $stmt->bind_param("iiis", $order_id, $product_id, $quantity, $packaging_type);
    $stmt->execute();
    $stmt->close();

    // Optionally: Deduct finished goods and packaging materials here

    // Generate a slip (for demo purposes, simply output order details)
    echo "<h3>Order Processed Successfully!</h3>";
    echo "<p>Order Date: " . $order_date . "</p>";
    echo "<p>Order Type: " . $order_type . "</p>";
    if ($order_type == 'Invoice') {
        echo "<p>Invoice Number: " . ($invoice_number ? $invoice_number : "Not Accounted") . "</p>";
    }
    echo "<p>Product ID: " . $product_id . "</p>";
    echo "<p>Quantity: " . $quantity . "</p>";
    echo "<p>Packaging: " . $packaging_type . "</p>";
    echo "<p><a href='pages/orders.php'>Back to Orders</a></p>";
}
?>

MMCT - 2023