Customer Job / Invoice Form
Record jobs, set deadlines, process invoices and manage delivery queues.
Live Print Preview
DynamicPRINT & GIFT PRO
123 Horizon Avenue, Tech Park
Tel: +91 9876543210
DOCUMENT TYPE
Job Card
DATE
Name: John Doe
Mobile: -
Address: -
ITEMS & INSTRUCTIONS
Cart is empty. Add items to preview.
JOB DEADLINE: N/A
Instructions: -
Total Value:
₹0.00
Advance Paid:
₹0.00
Balance Due:
₹0.00
Authorized Signature & Seal
Thank you for your business!
Total Orders
0
+8% this week
Pending/Ongoing Jobs
0
Requires fulfillment
Revenue Collected
₹0
Cash/Card/UPI transactions
Total Balance / Due
₹0
Awaiting final delivery/pickupRecent Orders & Job Cards
Track all received enquiries, job execution status, and sales.
| Ref ID | Customer | Type | Item Summary | Delivery By | Status | Total (₹) | Balance Due | Actions |
|---|
Add / Edit Item or Service
Populate the order dropdown menu with new inventory or service lines.
Available Catalog
| Item / Service Description | Category | Type | Standard Rate (₹) | Action |
|---|
Back-end Hub: Core PHP & MySQL Architecture
Below is the complete database schema and corresponding PHP endpoints explicitly satisfying the Core PHP/DB schema request without any frameworks.
-- ======================================================
-- DATABASE SCHEMA FOR PRINT & GIFT SUITE
-- Compatible with MySQL 8.0+
-- ======================================================
CREATE DATABASE IF NOT EXISTS `print_gift_shop` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE `print_gift_shop`;
-- 1. Customers Table
CREATE TABLE `customers` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(100) NOT NULL,
`mobile` VARCHAR(15) NOT NULL,
`address` TEXT NOT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- 2. Items/Services (Inventory) Table
CREATE TABLE `items_services` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(255) NOT NULL,
`category` ENUM('Engraving', 'Printing', 'Cards', 'Copying/Binding', 'Rubber Stamps', 'Lamination', 'Stationery') NOT NULL,
`type` ENUM('Service', 'Product') NOT NULL,
`standard_price` DECIMAL(10, 2) NOT NULL DEFAULT 0.00,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- 3. Orders / Jobs Table
CREATE TABLE `orders` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`order_type` ENUM('job', 'sale') NOT NULL,
`customer_id` INT NOT NULL,
`delivery_datetime` DATETIME DEFAULT NULL,
`total_amount` DECIMAL(10, 2) NOT NULL DEFAULT 0.00,
`advance_paid` DECIMAL(10, 2) NOT NULL DEFAULT 0.00,
`payment_mode` ENUM('Cash', 'UPI', 'Card') NOT NULL,
`transaction_ref` VARCHAR(100) DEFAULT NULL,
`special_instructions` TEXT DEFAULT NULL,
`status` ENUM('Pending', 'Processing', 'Delivered', 'Cancelled') DEFAULT 'Pending',
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE CASCADE
);
-- 4. Order Details (Cart items) Table
CREATE TABLE `order_items` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`order_id` INT NOT NULL,
`item_name` VARCHAR(255) NOT NULL,
`material_subtype` VARCHAR(50) DEFAULT NULL,
`quantity` INT NOT NULL DEFAULT 1,
`unit_price` DECIMAL(10, 2) NOT NULL DEFAULT 0.00,
FOREIGN KEY (`order_id`) REFERENCES `orders`(`id`) ON DELETE CASCADE
);
-- Insert Default Seed Catalog Items
INSERT INTO `items_services` (`name`, `category`, `type`, `standard_price`) VALUES
('Laser Engraving on Metal Trophy', 'Engraving', 'Service', 450.00),
('Photo Engraving on Wooden Plaque', 'Engraving', 'Service', 650.00),
('Porcelain/Mug Color Printing', 'Printing', 'Service', 250.00),
('Custom T-Shirt Fabric Printing', 'Printing', 'Service', 350.00),
('Flex Banner/Signage (Per SqFt)', 'Printing', 'Service', 25.00),
('Visiting Cards (Set of 100)', 'Cards', 'Service', 180.00),
('Rubber Stamp Manufacturing (Pre-inked)', 'Rubber Stamps', 'Service', 200.00),
('High-Grade Lamination (A4)', 'Lamination', 'Service', 30.00),
('Premium Executive Pen Set', 'Stationery', 'Product', 120.00),
('Hardbound Office Diary / Notebook', 'Stationery', 'Product', 150.00);
<?php
/**
* ==============================================================
* CORE PHP PROCESSOR: process_order.php (Strict Syntax & Validation)
* Handles customer insertion, order records, security & validation.
* ==============================================================
*/
header('Content-Type: application/json');
// 1. Establish PDO Database Connection
$host = 'localhost';
$db = 'print_gift_shop';
$user = 'root';
$pass = '';
try {
$pdo = new PDO("mysql:host=$host;dbname=$db;charset=utf8mb4", $user, $pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
http_response_code(500);
echo json_encode(['status' => 'error', 'message' => 'Database connection failed.']);
exit;
}
// 2. Validate request method
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo json_encode(['status' => 'error', 'message' => 'Method Not Allowed.']);
exit;
}
// 3. Read and sanitize incoming POST body
$input = json_decode(file_get_contents('php://input'), true);
if (!$input) {
echo json_encode(['status' => 'error', 'message' => 'Invalid JSON payload.']);
exit;
}
// 4. Strict Validation
$customerName = filter_var($input['customerName'] ?? '', FILTER_SANITIZE_STRING);
$mobile = filter_var($input['mobile'] ?? '', FILTER_SANITIZE_STRING);
$address = filter_var($input['address'] ?? '', FILTER_SANITIZE_STRING);
$orderType = in_array($input['orderType'] ?? '', ['job', 'sale']) ? $input['orderType'] : 'job';
$deliveryDate = $input['deliveryDate'] ?? null;
$totalAmount = filter_var($input['totalAmount'] ?? 0, FILTER_VALIDATE_FLOAT);
$advancePaid = filter_var($input['advancePaid'] ?? 0, FILTER_VALIDATE_FLOAT);
$paymentMode = in_array($input['paymentMode'] ?? 'Cash', ['Cash', 'UPI', 'Card']) ? $input['paymentMode'] : 'Cash';
$items = $input['items'] ?? [];
if (empty($customerName) || empty($mobile) || empty($items)) {
echo json_encode(['status' => 'error', 'message' => 'Missing critical order/customer fields.']);
exit;
}
// 5. Transaction Block
try {
$pdo->beginTransaction();
// A. Insert/Update Customer Profile
$stmt = $pdo->prepare("INSERT INTO customers (name, mobile, address) VALUES (?, ?, ?)");
$stmt->execute([$customerName, $mobile, $address]);
$customerId = $pdo->lastInsertId();
// B. Insert Order / Job Card
$stmt = $pdo->prepare("INSERT INTO orders (order_type, customer_id, delivery_datetime, total_amount, advance_paid, payment_mode, special_instructions) VALUES (?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([
$orderType,
$customerId,
$deliveryDate,
$totalAmount,
$advancePaid,
$paymentMode,
$input['instructions'] ?? ''
]);
$orderId = $pdo->lastInsertId();
// C. Insert Order Items line-by-line
$stmtItem = $pdo->prepare("INSERT INTO order_items (order_id, item_name, quantity, unit_price) VALUES (?, ?, ?, ?)");
foreach ($items as $item) {
$stmtItem->execute([
$orderId,
$item['name'],
(int)$item['qty'],
(float)$item['price']
]);
}
$pdo->commit();
echo json_encode([
'status' => 'success',
'message' => 'Order / Job Card successfully generated!',
'orderId' => $orderId
]);
} catch (Exception $e) {
$pdo->rollBack();
http_response_code(500);
echo json_encode(['status' => 'error', 'message' => 'Transaction failed: ' . $e->getMessage()]);
}
?>