« Back to History
edit.php
|
20260722_120325.php
Initial Domain Snapshot
Copy Code
<?php require_once __DIR__ . '/../includes/bootstrap.php'; require_once __DIR__ . '/../includes/header.php'; require_once __DIR__ . '/../includes/sidebar.php'; $id = max(0, (int)($_GET['id'] ?? 0)); $errMessage = ''; $successMessage = ''; try { $stmt = $pdo->prepare("SELECT * FROM tenant_master WHERE tenant_id = ? LIMIT 1"); $stmt->execute([$id]); $tenant = $stmt->fetch(); } catch (PDOException $e) { $tenant = false; } if (!$tenant) { echo '<div class="alert alert-danger m-3">Customer entity parameter tracking context missed.</div>'; require_once __DIR__ . '/../includes/footer.php'; exit; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $tenant_name = trim($_POST['tenant_name'] ?? ''); $contact_person = trim($_POST['contact_person'] ?? ''); $mobile = trim($_POST['mobile'] ?? ''); $email = trim($_POST['email'] ?? ''); $address = trim($_POST['address'] ?? ''); $status = trim($_POST['status'] ?? 'ACTIVE'); if (empty($tenant_name) || empty($contact_person) || empty($mobile)) { $errMessage = "Customer Name, Contact Person, and Mobile fields cannot be empty values."; } else { try { $pdo->beginTransaction(); // Validate Unique Mobile Constraint Exclude Current Node ID $chkMob = $pdo->prepare("SELECT tenant_id FROM tenant_master WHERE mobile = ? AND tenant_id != ? LIMIT 1"); $chkMob->execute([$mobile, $id]); if ($chkMob->fetch()) { throw new Exception("Validation Lockout: This mobile metric tracking context is bound to another tenant."); } // Validate Unique Email Constraint Exclude Current Node ID if (!empty($email)) { $chkEmail = $pdo->prepare("SELECT tenant_id FROM tenant_master WHERE email = ? AND tenant_id != ? LIMIT 1"); $chkEmail->execute([$email, $id]); if ($chkEmail->fetch()) { throw new Exception("Validation Lockout: This email parameter workspace tracking context is bound to another tenant."); } } $updStmt = $pdo->prepare("UPDATE tenant_master SET tenant_name = ?, contact_person = ?, mobile = ?, email = ?, address = ?, status = ? WHERE tenant_id = ?"); $updStmt->execute([ $tenant_name, $contact_person, $mobile, (!empty($email) ? $email : null), (!empty($address) ? $address : null), $status, $id ]); $pdo->commit(); header("Location: /admin/customer/list.php"); exit; } catch (Exception $e) { $pdo->rollBack(); $errMessage = $e->getMessage(); } } } ?> <div class="container-fluid p-0" style="max-width: 1000px;"> <div class="d-flex justify-content-between align-items-center mb-4"> <h4 class="m-0 fw-bold text-dark">Edit Customer Workspace Settings</h4> <a href="/admin/customer/list.php" class="btn btn-sm btn-outline-secondary">Cancel Changes</a> </div> <?php if (!empty($errMessage)): ?> <div class="alert alert-danger small"><?= htmlspecialchars($errMessage) ?></div> <?php endif; ?> <div class="card border-0 shadow-sm bg-white p-4"> <form action="edit.php?id=<?= $id ?>" method="POST"> <div class="row g-3"> <div class="col-md-6"> <label class="form-label small fw-semibold text-muted">System Generated Tenant Code (Immutable)</label> <input type="text" class="form-control form-control-sm bg-light fw-bold" value="<?= htmlspecialchars($tenant['tenant_code']) ?>" readonly> </div> <div class="col-md-6"> <label class="form-label small fw-semibold">Customer / Organization Name *</label> <input type="text" name="tenant_name" class="form-control form-control-sm" value="<?= htmlspecialchars($tenant['tenant_name']) ?>" required> </div> <div class="col-md-6"> <label class="form-label small fw-semibold">Contact Person *</label> <input type="text" name="contact_person" class="form-control form-control-sm" value="<?= htmlspecialchars($tenant['contact_person']) ?>" required> </div> <div class="col-md-6"> <label class="form-label small fw-semibold">Mobile *</label> <input type="text" name="mobile" class="form-control form-control-sm" value="<?= htmlspecialchars($tenant['mobile']) ?>" required> </div> <div class="col-md-6"> <label class="form-label small fw-semibold">Email Address</label> <input type="email" name="email" class="form-control form-control-sm" value="<?= htmlspecialchars($tenant['email'] ?? '') ?>"> </div> <div class="col-md-6"> <label class="form-label small fw-semibold">Infrastructure Operational Status</label> <select name="status" class="form-select form-select-sm" required> <option value="ACTIVE" <?= $tenant['status'] === 'ACTIVE' ? 'selected' : '' ?>>ACTIVE</option> <option value="SUSPENDED" <?= $tenant['status'] === 'SUSPENDED' ? 'selected' : '' ?>>SUSPENDED</option> </select> </div> <div class="col-md-12"> <label class="form-label small fw-semibold">Address Parameter Profile</label> <textarea name="address" class="form-control form-control-sm" rows="3"><?= htmlspecialchars($tenant['address'] ?? '') ?></textarea> </div> </div> <div class="mt-4 border-top pt-3 text-end"> <button type="submit" class="btn btn-sm btn-primary px-4">Persist Dynamic Metrics</button> </div> </form> </div> </div> <?php require_once __DIR__ . '/../includes/footer.php'; ?>