🤩 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:view_quotations.php
<?php require_once 'header.php'; $msg = ''; // Update Status if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update_status'])) { $id = $_POST['quotation_id']; $status = $_POST['status']; try { $stmt = $pdo->prepare("UPDATE quotations SET status = ? WHERE id = ?"); $stmt->execute([$status, $id]); $msg = "<div class='alert alert-success'>Status updated.</div>"; } catch(Exception $e) { $msg = "<div class='alert alert-danger'>Error updating status.</div>"; } } if (isset($_GET['id'])) { // Single View $id = $_GET['id']; $stmt = $pdo->prepare("SELECT * FROM quotations WHERE id = ?"); $stmt->execute([$id]); $quote = $stmt->fetch(); if (!$quote) { echo "<div class='alert alert-danger'>Quotation not found.</div>"; require_once 'footer.php'; exit; } // Fetch files $stmt = $pdo->prepare("SELECT * FROM quotation_files WHERE quotation_id = ?"); $stmt->execute([$id]); $files = $stmt->fetchAll(); ?> <div class="d-flex justify-content-between align-items-center mb-4"> <h2>Quotation #<?= $quote['id'] ?> Details</h2> <a href="view_quotations.php" class="btn btn-secondary">Back to List</a> </div> <?= $msg ?> <div class="row"> <div class="col-lg-8"> <div class="card mb-4"> <div class="card-header bg-dark text-white">Client Information & Requirements</div> <div class="card-body"> <table class="table table-borderless"> <tr><th style="width: 200px;">Service Type:</th><td><span class="badge bg-gold text-dark fs-6"><?= e($quote['quotation_type']) ?></span></td></tr> <tr><th>Client Name:</th><td><?= e($quote['name']) ?></td></tr> <tr><th>Location:</th><td><?= e($quote['location']) ?></td></tr> <tr><th>Contact Number:</th><td> <a href="https://wa.me/94<?= ltrim($quote['contact_number'], '0') ?>" target="_blank" class="text-success text-decoration-none"> <i class="fab fa-whatsapp me-1"></i> <?= e($quote['contact_number']) ?> </a> </td></tr> <?php if($quote['quotation_type'] == 'Pantry Cupboard'): ?> <tr><th>Pantry Shape:</th><td><?= e($quote['shape']) ?></td></tr> <?php if($quote['shape'] == 'Straight'): ?> <tr><th>Length:</th><td><?= e($quote['side1']) ?></td></tr> <?php elseif($quote['shape'] == 'L-Shape'): ?> <tr><th>Side A:</th><td><?= e($quote['side1']) ?></td></tr> <tr><th>Side B:</th><td><?= e($quote['side2']) ?></td></tr> <?php elseif($quote['shape'] == 'U-Shape'): ?> <tr><th>Side A:</th><td><?= e($quote['side1']) ?></td></tr> <tr><th>Middle:</th><td><?= e($quote['side2']) ?></td></tr> <tr><th>Side C:</th><td><?= e($quote['side3']) ?></td></tr> <?php endif; ?> <?php else: ?> <tr><th>Height:</th><td><?= e($quote['height']) ?></td></tr> <tr><th>Width:</th><td><?= e($quote['width']) ?></td></tr> <?php endif; ?> <tr><th>Additional Requirements:</th><td><?= nl2br(e($quote['additional_req'])) ?: '<span class="text-muted">None</span>' ?></td></tr> </table> </div> </div> <div class="card mb-4"> <div class="card-header">Uploaded Reference Files</div> <div class="card-body"> <?php if(empty($files)): ?> <p class="text-muted mb-0">No files uploaded for this request.</p> <?php else: ?> <div class="row g-3"> <?php foreach($files as $f): ?> <div class="col-md-6"> <div class="border rounded p-2 text-center"> <span class="d-block mb-2 text-muted small fw-bold"><?= e($f['file_type']) ?></span> <a href="../uploads/quotations/<?= e($f['file_name']) ?>" target="_blank"> <img src="../uploads/quotations/<?= e($f['file_name']) ?>" alt="File" class="img-fluid rounded" style="max-height: 200px; object-fit: contain;"> </a> </div> </div> <?php endforeach; ?> </div> <?php endif; ?> </div> </div> </div> <div class="col-lg-4"> <div class="card"> <div class="card-header bg-light">Update Status</div> <div class="card-body"> <form method="POST"> <input type="hidden" name="update_status" value="1"> <input type="hidden" name="quotation_id" value="<?= $quote['id'] ?>"> <div class="mb-3"> <label class="form-label">Current Status</label> <select name="status" class="form-select"> <option value="Pending" <?= $quote['status'] == 'Pending' ? 'selected' : '' ?>>Pending</option> <option value="Reviewed" <?= $quote['status'] == 'Reviewed' ? 'selected' : '' ?>>Reviewed</option> <option value="Completed" <?= $quote['status'] == 'Completed' ? 'selected' : '' ?>>Completed</option> </select> </div> <button type="submit" class="btn btn-gold w-100">Save Status</button> </form> </div> </div> </div> </div> <?php } else { // List View try { $stmt = $pdo->query("SELECT * FROM quotations ORDER BY id DESC"); $quotes = $stmt->fetchAll(); } catch (PDOException $e) { if ($e->getCode() == '42S02') { $pdo->exec("CREATE TABLE IF NOT EXISTS `quotations` ( `id` int(11) NOT NULL AUTO_INCREMENT, `quotation_type` enum('Pantry Cupboard','TV Wall','Wardrobe','Partition Wall') NOT NULL, `name` varchar(150) NOT NULL, `location` varchar(255) NOT NULL, `contact_number` varchar(20) NOT NULL, `shape` enum('Straight','L-Shape','U-Shape') DEFAULT NULL, `side1` varchar(50) DEFAULT NULL, `side2` varchar(50) DEFAULT NULL, `side3` varchar(50) DEFAULT NULL, `height` varchar(50) DEFAULT NULL, `width` varchar(50) DEFAULT NULL, `additional_req` text DEFAULT NULL, `status` enum('Pending','Reviewed','Completed') NOT NULL DEFAULT 'Pending', `created_at` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"); $quotes = []; } else { echo "<div class='alert alert-danger'>Database Error: " . htmlspecialchars($e->getMessage()) . "</div>"; $quotes = []; } } ?> <h2 class="mb-4">All Quotation Requests</h2> <div class="card"> <div class="card-body p-0"> <div class="table-responsive"> <table class="table table-hover mb-0"> <thead class="table-light"> <tr> <th>ID</th> <th>Date</th> <th>Client Name</th> <th>Service</th> <th>Location</th> <th>Status</th> <th>Action</th> </tr> </thead> <tbody> <?php foreach($quotes as $q): ?> <tr> <td>#<?= $q['id'] ?></td> <td><?= date('M d, Y h:i A', strtotime($q['created_at'])) ?></td> <td><?= e($q['name']) ?></td> <td><span class="badge bg-secondary"><?= e($q['quotation_type']) ?></span></td> <td><?= e($q['location']) ?></td> <td> <?php if($q['status'] == 'Pending'): ?> <span class="badge bg-warning text-dark">Pending</span> <?php elseif($q['status'] == 'Reviewed'): ?> <span class="badge bg-info">Reviewed</span> <?php else: ?> <span class="badge bg-success">Completed</span> <?php endif; ?> </td> <td> <a href="?id=<?= $q['id'] ?>" class="btn btn-sm btn-primary">View Details</a> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> </div> </div> <?php } require_once 'footer.php'; ?>
Save Changes
Cancel
Create New File
Create New Folder