Server : LiteSpeed
System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User : outerorb ( 1091)
PHP Version : 8.1.34
Disable Function : mail
Directory :  /home2/outerorb/emp.outerorbittech.in/admin/

πŸ“ Create New:
⬆️ Upload File:
Current Dir [ Writable ] Root [ Writable ]


OR Upload from URL:
URL: Save as:

πŸ“„ File: trash.php

Path: /home2/outerorb/emp.outerorbittech.in/admin/trash.php

Size: 14.86 KB

Permissions: 0666

<?php
require __DIR__ . '/../includes/helpers.php';
require_admin();
ensure_employees_table();

$roleLabel = 'Admin';
$flash = flash();
$q = isset($_GET['q']) ? sanitize_text($_GET['q']) : '';
$statusOptions = ['Active', 'Left', 'Terminated', 'Absconded / Defaulted', 'All'];
$status = isset($_GET['status']) ? sanitize_text($_GET['status']) : 'All';
if (!in_array($status, $statusOptions, true)) {
    $status = 'All';
}
$departments = list_departments();
$departmentFilter = isset($_GET['department']) ? sanitize_text($_GET['department']) : '';
if ($departmentFilter !== '' && !in_array($departmentFilter, $departments, true)) {
    $departmentFilter = '';
}

$pdo = db();
$sql = 'SELECT e.* FROM employees e';
$where = ['e.deleted_at IS NOT NULL'];
$params = [];
$statusColumn = 'e.employee_status';

if ($status !== 'All') {
    $where[] = "{$statusColumn} = :status";
    $params[':status'] = $status;
}

if ($departmentFilter !== '') {
    $where[] = 'e.department = :department';
    $params[':department'] = $departmentFilter;
}

apply_department_filter($where, $params, 'e');

if ($q !== '') {
    $where[] = '(e.first_name LIKE :q_fn OR e.last_name LIKE :q_ln OR e.email LIKE :q_em OR e.phone LIKE :q_ph)';
    $params[':q_fn'] = "%{$q}%";
    $params[':q_ln'] = "%{$q}%";
    $params[':q_em'] = "%{$q}%";
    $params[':q_ph'] = "%{$q}%";
}

if (!empty($where)) {
    $sql .= ' WHERE ' . implode(' AND ', $where);
}
$sql .= ' ORDER BY e.deleted_at DESC, e.created_at DESC';
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
$employees = $stmt->fetchAll();
$total = count($employees);
$latest = $employees[0] ?? null;

$docColumns = [
    'aadhaar_path',
    'pan_path',
    'tenth_marksheet_path',
    'twelfth_marksheet_path',
    'bank_proof_path',
    'photo_path',
];

$pendingCountFor = function (array $emp) use ($docColumns): int {
    $missing = 0;
    foreach ($docColumns as $col) {
        if (!resolve_upload_path($emp[$col] ?? null)) {
            $missing++;
        }
    }
    return $missing;
};

$statusClasses = [
    'Active' => 'status-active',
    'Left' => 'status-left',
    'Terminated' => 'status-terminated',
    'Absconded / Defaulted' => 'status-absconded',
];
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Trash</title>
    <link rel="stylesheet" href="../assets/css/style.css" />
    <link rel="stylesheet" href="../assets/css/polish.css">
</head>
<body class="dashboard-layout">
<div class="app-wrapper">
    <!-- Include Sidebar -->
    <?php require '_sidebar.php'; ?>

    <!-- MAIN CONTENT -->
    <div class="main-content">
        <!-- Top Bar -->
        <div class="top-bar">
            <div class="top-bar-left">
                <button class="sidebar-toggle" id="sidebarToggle" aria-label="Toggle sidebar">☰</button>
                <div>
                    <h1 class="page-title">Trash</h1>
                    <div class="breadcrumb-nav">
                        <span>Restore or permanently delete employees</span>
                    </div>
                </div>
            </div>
            <div class="top-bar-right">
                <a href="dashboard.php" style="color: #cbd5e1; text-decoration: none; padding: 8px 12px; border-radius: 6px; transition: background 0.15s; font-size: 13px; font-weight: 600;" title="Back">← Dashboard</a>
            </div>
        </div>

        <!-- Page Content -->
        <div class="dashboard-container" style="max-width: 1200px;">
<div class="container">

    <?php if ($flash): ?>
        <div class="alert <?php echo $flash['type'] === 'error' ? 'alert-error' : 'alert-success'; ?>">
            <?php echo htmlspecialchars($flash['message'], ENT_QUOTES, 'UTF-8'); ?>
        </div>
    <?php endif; ?>

    <div class="card">
        <div class="stats-grid">
            <div class="stat-card">
                <div class="stat-label">Total Trashed</div>
                <div class="stat-value"><?php echo $total; ?></div>
            </div>
            <div class="stat-card">
                <div class="stat-label">Latest Trashed</div>
                <div class="stat-value"><?php echo $latest ? htmlspecialchars($latest['deleted_at'], ENT_QUOTES, 'UTF-8') : 'β€”'; ?></div>
            </div>
            <div class="stat-card">
                <div class="stat-label">Last Submitted By</div>
                <div class="stat-value"><?php echo $latest ? htmlspecialchars($latest['first_name'] . ' ' . $latest['last_name'], ENT_QUOTES, 'UTF-8') : 'β€”'; ?></div>
            </div>
        </div>

        <form class="search-bar" method="get" action="trash.php">
            <input class="input-inline" type="text" name="q" value="<?php echo htmlspecialchars($q, ENT_QUOTES, 'UTF-8'); ?>" placeholder="Search name, email, or phone" />
            <select name="status" class="input-inline" style="max-width: 180px;">
                <?php foreach ($statusOptions as $opt): ?>
                    <option value="<?php echo htmlspecialchars($opt, ENT_QUOTES, 'UTF-8'); ?>" <?php echo $status === $opt ? 'selected' : ''; ?>><?php echo htmlspecialchars($opt, ENT_QUOTES, 'UTF-8'); ?></option>
                <?php endforeach; ?>
            </select>
            <select name="department" class="input-inline" style="max-width: 200px;">
                <option value="">All Departments</option>
                <?php foreach ($departments as $dept): ?>
                    <option value="<?php echo htmlspecialchars($dept, ENT_QUOTES, 'UTF-8'); ?>" <?php echo $departmentFilter === $dept ? 'selected' : ''; ?>><?php echo htmlspecialchars($dept, ENT_QUOTES, 'UTF-8'); ?></option>
                <?php endforeach; ?>
            </select>
            <button type="submit">Search</button>
            <a class="button-ghost" href="trash.php" style="padding:10px 12px;">Reset</a>
        </form>

        <div class="table-wrapper">
            <table class="table">
                <thead>
                    <tr>
                        <th class="cell-nowrap">Full Name</th>
                        <th class="cell-nowrap">Date of Joining</th>
                        <th>Contact Number</th>
                        <th>Email</th>
                        <th class="cell-nowrap">Emergency Contact</th>
                        <th>Department / Process</th>
                        <th class="cell-nowrap col-status">Status</th>
                        <th class="cell-nowrap">Pending Docs</th>
                        <th class="col-docs">Docs</th>
                        <th class="col-actions">Actions</th>
                    </tr>
                </thead>
                <tbody>
                <?php if (empty($employees)): ?>
                    <tr><td colspan="10">No trashed records.</td></tr>
                <?php else: ?>
                    <?php foreach ($employees as $emp): ?>
                        <?php $pendingCount = $pendingCountFor($emp); ?>
                        <tr>
                            <td class="cell-nowrap">
                                <?php
                                $hasPhoto = (bool) resolve_upload_path($emp['photo_path'] ?? null);
                                $photoUrl = $hasPhoto
                                    ? 'download.php?id=' . $emp['id'] . '&type=photo&mode=inline'
                                    : 'data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2240%22 height=%2240%22 viewBox=%220 0 80 80%22%3E%3Crect width=%2280%22 height=%2280%22 rx=%2240%22 fill=%22%23e5e7eb%22/%3E%3Cpath fill=%22%239ca3af%22 d=%22M40 12a14 14 0 1 1 0 28 14 14 0 0 1 0-28Zm0 32c11.046 0 20 6.268 20 14v6H20v-6c0-7.732 8.954-14 20-14Z%22/%3E%3C/svg%3E';
                                ?>
                                <span class="avatar-wrap">
                                    <img src="<?php echo htmlspecialchars($photoUrl, ENT_QUOTES, 'UTF-8'); ?>" loading="lazy" alt="Photo" class="avatar-thumb" />
                                    <?php if ($hasPhoto): ?>
                                        <img src="<?php echo htmlspecialchars($photoUrl, ENT_QUOTES, 'UTF-8'); ?>" alt="Photo preview" class="avatar-preview" />
                                    <?php endif; ?>
                                    <span>
                                        <span class="name-line"><?php echo htmlspecialchars($emp['first_name'], ENT_QUOTES, 'UTF-8'); ?></span>
                                        <span class="subtext">Father: <?php echo htmlspecialchars($emp['last_name'], ENT_QUOTES, 'UTF-8'); ?></span>
                                        <span class="subtext">Deleted: <?php echo htmlspecialchars($emp['deleted_at'] ?? '', ENT_QUOTES, 'UTF-8'); ?></span>
                                    </span>
                                </span>
                            </td>
                            <td class="cell-nowrap"><?php echo htmlspecialchars($emp['date_of_joining'] ?? '', ENT_QUOTES, 'UTF-8'); ?></td>
                            <td><?php echo htmlspecialchars($emp['phone'], ENT_QUOTES, 'UTF-8'); ?></td>
                            <td><?php echo htmlspecialchars($emp['email'], ENT_QUOTES, 'UTF-8'); ?></td>
                            <td class="cell-nowrap">
                                <div><?php echo htmlspecialchars($emp['emergency_contact_name'] ?? '', ENT_QUOTES, 'UTF-8'); ?></div>
                                <span class="subtext"><?php echo htmlspecialchars($emp['emergency_contact_number'] ?? '', ENT_QUOTES, 'UTF-8'); ?><?php echo !empty($emp['emergency_contact_relation']) ? ' Ò€’ ' . htmlspecialchars($emp['emergency_contact_relation'], ENT_QUOTES, 'UTF-8') : ''; ?></span>
                            </td>
                            <td><?php echo htmlspecialchars($emp['department'] ?? '', ENT_QUOTES, 'UTF-8'); ?></td>
                            <?php $statusLabel = $emp['employee_status'] ?? 'Active'; ?>
                            <?php $statusClass = $statusClasses[$statusLabel] ?? 'status-active'; ?>
                            <td class="cell-nowrap">
                                <span class="badge status-badge <?php echo $statusClass; ?>"><?php echo htmlspecialchars($statusLabel, ENT_QUOTES, 'UTF-8'); ?></span>
                                <?php if (!empty($emp['last_working_date']) && $statusLabel !== 'Active'): ?>
                                    <span class="subtext">Last day: <?php echo htmlspecialchars($emp['last_working_date'], ENT_QUOTES, 'UTF-8'); ?></span>
                                <?php endif; ?>
                            </td>
                            <td class="cell-nowrap">
                                <?php if ($pendingCount === 0): ?>
                                    <span class="badge">0</span>
                                <?php else: ?>
                                    <span class="badge" style="background:#f59e0b;color:#1f2937;"><?php echo $pendingCount; ?></span>
                                <?php endif; ?>
                            </td>
                            <td class="col-docs" style="text-align:center;">
                                <div class="doc-menu">
                                    <span class="doc-menu-toggle" title="Documents" aria-label="Documents">Γ°ΕΈβ€œΒ</span>
                                    <div class="doc-menu-list">
                                        <a href="download.php?id=<?php echo $emp['id']; ?>&type=aadhaar">Aadhaar</a>
                                        <a href="download.php?id=<?php echo $emp['id']; ?>&type=pan">PAN</a>
                                        <a href="download.php?id=<?php echo $emp['id']; ?>&type=qualification">Graduation</a>
                                        <a href="download.php?id=<?php echo $emp['id']; ?>&type=tenth_marksheet">10th Marksheet</a>
                                        <a href="download.php?id=<?php echo $emp['id']; ?>&type=twelfth_marksheet">12th Marksheet</a>
                                        <a href="download.php?id=<?php echo $emp['id']; ?>&type=bank_proof">Bank Proof</a>
                                        <a href="download.php?id=<?php echo $emp['id']; ?>&type=photo">Photo</a>
                                    </div>
                                </div>
                            </td>
                            <td class="col-actions">
                                <div class="row-actions">
                                    <div class="action-menu">
                                        <button type="button" class="action-toggle">Actions Ò–¾</button>
                                        <div class="action-menu-list">
                                            <form method="post" action="restore.php" style="margin:0;">
                                                <input type="hidden" name="csrf_token" value="<?php echo csrf_token(); ?>" />
                                                <input type="hidden" name="id" value="<?php echo $emp['id']; ?>" />
                                                <button type="submit">Restore</button>
                                            </form>
                                            <form method="post" action="delete.php" onsubmit="return confirm('Permanently delete this record? This will remove all files and data.');" style="margin:0;">
                                                <input type="hidden" name="csrf_token" value="<?php echo csrf_token(); ?>" />
                                                <input type="hidden" name="id" value="<?php echo $emp['id']; ?>" />
                                                <input type="hidden" name="force_delete" value="1" />
                                                <button type="submit">Permanent Delete</button>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
        </div>
        </div>
    </div>
</div>

<div class="sidebar-overlay" id="sidebarOverlay"></div>

<script>
    // Sidebar Toggle
    const sidebar = document.getElementById('sidebar');
    const sidebarToggle = document.getElementById('sidebarToggle');
    const sidebarOverlay = document.getElementById('sidebarOverlay');

    sidebarToggle?.addEventListener('click', () => {
        sidebar.classList.toggle('open');
        sidebarOverlay.classList.toggle('open');
    });

    sidebarOverlay?.addEventListener('click', () => {
        sidebar.classList.remove('open');
        sidebarOverlay.classList.remove('open');
    });
</script>

</body>
</html>



← Back to Directory Edit File πŸ”’ Chmod

WP File Manager