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: view.php

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

Size: 17.14 KB

Permissions: 0666

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

$roleLabel = 'Admin';
$flash = flash();
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;

if (!$id) {
    redirect_with_message('dashboard.php', 'Invalid record.', 'error');
}

$pdo = db();
$stmt = $pdo->prepare('SELECT e.*, d.name AS designation_name, d.status AS designation_status FROM employees e LEFT JOIN designations d ON e.designation_id = d.id WHERE e.id = ? LIMIT 1');
$stmt->execute([$id]);
$emp = $stmt->fetch();
$aadhaarPaths = parse_aadhaar_paths($emp['aadhaar_path'] ?? '');

if (!$emp) {
    redirect_with_message('dashboard.php', 'Record not found.', 'error');
}

enforce_department_access($emp);

if (!empty($emp['deleted_at'])) {
    redirect_with_message('trash.php', 'Record is in Trash. Restore it to view in detail.', 'error');
}

$docs = [
    'aadhaar' => ['label' => 'Aadhaar', 'col' => 'aadhaar_path'],
    'pan' => ['label' => 'PAN', 'col' => 'pan_path'],
    'qualification' => ['label' => 'Graduation', 'col' => 'qualification_path'],
    'tenth_marksheet' => ['label' => '10th Marksheet', 'col' => 'tenth_marksheet_path'],
    'twelfth_marksheet' => ['label' => '12th Marksheet', 'col' => 'twelfth_marksheet_path'],
    'bank_proof' => ['label' => 'Bank Proof', 'col' => 'bank_proof_path'],
    'photo' => ['label' => 'Passport Photo', 'col' => 'photo_path'],
];

$pendingDocs = [];
foreach ($docs as $key => $doc) {
    if ($key === 'aadhaar') {
        $paths = array_filter([$aadhaarPaths['front'] ?? null, $aadhaarPaths['back'] ?? null, $aadhaarPaths['single'] ?? null]);
        $hasAny = false;
        foreach ($paths as $candidate) {
            if (resolve_upload_path($candidate)) {
                $hasAny = true;
                break;
            }
        }
        if (!$hasAny) {
            $pendingDocs[] = $doc['label'];
        }
        continue;
    }

    if ($key === 'qualification') {
        continue;
    }

    $path = $emp[$doc['col']] ?? '';
    if (!resolve_upload_path($path)) {
        $pendingDocs[] = $doc['label'];
    }
}

$statusClasses = [
    'Active' => 'status-active',
    'Left' => 'status-left',
    'Terminated' => 'status-terminated',
    'Absconded / Defaulted' => 'status-absconded',
];
$employeeStatus = $emp['employee_status'] ?? 'Active';
$statusClass = $statusClasses[$employeeStatus] ?? 'status-active';

$companyName = 'Outer Orbit Technologies Private Limited';

function e(string $value): string
{
    return htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
}

function display_value(?string $value, bool $allowBreaks = false): string
{
    $clean = trim((string) $value);
    if ($clean === '') {
        return '—';
    }

    $escaped = e($clean);
    return $allowBreaks ? nl2br($escaped) : $escaped;
}

function is_image_file(string $path): bool
{
    $mime = detect_mime_type($path);
    return strpos($mime, 'image/') === 0;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>View Record</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">View Employee Record</h1>
                    <div class="breadcrumb-nav">
                        <span>View and print submission</span>
                    </div>
                </div>
            </div>
            <div class="top-bar-right">
                <a href="edit.php?id=<?php echo $emp['id']; ?>" style="color: #cbd5e1; text-decoration: none; padding: 8px 12px; border-radius: 6px; transition: background 0.15s; font-size: 13px; font-weight: 600;" title="Edit">Edit</a>
                <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 document-container">

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

    <?php
    $personalFields = [
        ['label' => 'FULL NAME', 'value' => $emp['first_name']],
        ['label' => "FATHER'S NAME", 'value' => $emp['last_name']],
        ['label' => "MOTHER'S NAME", 'value' => $emp['mother_name'] ?? ''],
        ['label' => 'DATE OF BIRTH', 'value' => $emp['dob']],
        ['label' => 'DATE OF JOINING', 'value' => $emp['date_of_joining']],
        ['label' => 'EMAIL', 'value' => $emp['email']],
        ['label' => 'CONTACT NUMBER', 'value' => $emp['phone']],
        ['label' => 'EMERGENCY CONTACT', 'value' => $emp['emergency_contact']],
        ['label' => 'GENDER', 'value' => $emp['gender']],
        ['label' => 'MARITAL STATUS', 'value' => $emp['marital_status']],
    ];

    $employmentFields = [
        ['label' => 'EMPLOYEE STATUS', 'value' => $employeeStatus],
        ['label' => 'LAST WORKING DATE', 'value' => $emp['last_working_date'] ?: ''],
        ['label' => 'REASON FOR LEAVING', 'value' => $emp['reason_for_leaving'] ?: ''],
        ['label' => 'DEPARTMENT / PROCESS', 'value' => $emp['department']],
        ['label' => 'DESIGNATION', 'value' => $emp['designation_name'] ?: ''],
        ['label' => 'HIGHEST QUALIFICATION', 'value' => $emp['highest_qualification']],
        ['label' => 'AADHAAR NUMBER', 'value' => $emp['aadhaar_number']],
        ['label' => 'PAN NUMBER', 'value' => $emp['pan_number']],
        ['label' => 'IDENTITY MARK', 'value' => $emp['identity_mark']],
        ['label' => 'BLOOD GROUP', 'value' => $emp['blood_group']],
    ];

    $addressFields = [
        ['label' => 'PRESENT ADDRESS', 'value' => $emp['address'], 'multiline' => true],
        ['label' => 'PERMANENT ADDRESS', 'value' => $emp['permanent_address'], 'multiline' => true],
        ['label' => 'PRESENT ZIP / PIN', 'value' => $emp['zip']],
    ];

    $emergencyFields = [
        ['label' => 'EMERGENCY CONTACT NAME', 'value' => $emp['emergency_contact_name'] ?? ''],
        ['label' => 'EMERGENCY CONTACT NUMBER', 'value' => $emp['emergency_contact_number'] ?? ''],
        ['label' => 'EMERGENCY CONTACT RELATION', 'value' => $emp['emergency_contact_relation'] ?? ''],
    ];

    $bankFields = [
        ['label' => 'ACCOUNT NUMBER', 'value' => $emp['account_number']],
        ['label' => 'IFSC CODE', 'value' => $emp['ifsc_code']],
        ['label' => 'BANK NAME', 'value' => $emp['bank_name']],
    ];

    $referralLookup = [
        'consultancy' => 'Consultancy',
        'person' => 'Person',
        'walkin' => 'Walk-in (Self)',
    ];

    $referralFields = [
        ['label' => 'REFERRED BY', 'value' => $referralLookup[$emp['referred_by'] ?? ''] ?? ''],
        ['label' => 'REFERRAL NAME', 'value' => $emp['referral_name'] ?: '—'],
    ];
    ?>

    <div class="document-sheet">
        <header class="doc-header">
            <div>
                <div class="company-name"><?php echo e($companyName); ?></div>
                <div class="doc-title">EMPLOYEE DETAILS FORM</div>
            </div>
            <div class="doc-meta">
                <div class="meta-line"><span class="meta-label">Employee ID</span><span class="meta-value">#<?php echo e((string) $emp['id']); ?></span></div>
                <div class="meta-line"><span class="meta-label">Date of Submission</span><span class="meta-value"><?php echo e($emp['created_at']); ?></span></div>
            </div>
        </header>

        <section class="doc-section">
            <h3>PERSONAL DETAILS</h3>
            <div class="doc-grid">
                <?php foreach ($personalFields as $field): ?>
                    <div class="doc-row">
                        <div class="doc-label"><?php echo e($field['label']); ?></div>
                        <div class="doc-value"><?php echo display_value($field['value']); ?></div>
                    </div>
                <?php endforeach; ?>
            </div>
        </section>

        <section class="doc-section">
            <h3>EMPLOYMENT DETAILS</h3>
            <div class="doc-grid">
                <?php foreach ($employmentFields as $field): ?>
                    <div class="doc-row">
                        <div class="doc-label"><?php echo e($field['label']); ?></div>
                        <div class="doc-value"><?php echo display_value($field['value']); ?></div>
                    </div>
                <?php endforeach; ?>
            </div>
        </section>

        <section class="doc-section">
            <h3>ADDRESS DETAILS</h3>
            <div class="doc-grid">
                <?php foreach ($addressFields as $field): ?>
                    <div class="doc-row">
                        <div class="doc-label"><?php echo e($field['label']); ?></div>
                        <div class="doc-value"><?php echo display_value($field['value'], !empty($field['multiline'])); ?></div>
                    </div>
                <?php endforeach; ?>
            </div>
        </section>

        <section class="doc-section">
            <h3>EMERGENCY CONTACT</h3>
            <div class="doc-grid">
                <?php foreach ($emergencyFields as $field): ?>
                    <div class="doc-row">
                        <div class="doc-label"><?php echo e($field['label']); ?></div>
                        <div class="doc-value"><?php echo display_value($field['value']); ?></div>
                    </div>
                <?php endforeach; ?>
            </div>
        </section>

        <section class="doc-section">
            <h3>BANK DETAILS</h3>
            <div class="doc-grid">
                <?php foreach ($bankFields as $field): ?>
                    <div class="doc-row">
                        <div class="doc-label"><?php echo e($field['label']); ?></div>
                        <div class="doc-value"><?php echo display_value($field['value']); ?></div>
                    </div>
                <?php endforeach; ?>
            </div>
        </section>

        <section class="doc-section">
            <h3>REFERRAL DETAILS</h3>
            <div class="doc-grid">
                <?php foreach ($referralFields as $field): ?>
                    <div class="doc-row">
                        <div class="doc-label"><?php echo e($field['label']); ?></div>
                        <div class="doc-value"><?php echo display_value($field['value']); ?></div>
                    </div>
                <?php endforeach; ?>
            </div>
        </section>

        <section class="doc-section documents-section">
            <h3>DOCUMENTS ATTACHED</h3>
            <?php if (!empty($pendingDocs)): ?>
                <p class="helper" style="color:#b91c1c;">Pending: <?php echo e(implode(', ', $pendingDocs)); ?></p>
            <?php else: ?>
                <p class="helper" style="color:#16a34a;">All documents uploaded.</p>
            <?php endif; ?>
            <table class="doc-table">
                <thead>
                <tr>
                    <th>Document</th>
                    <th>Status</th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($docs as $key => $doc): ?>
                    <?php if ($key === 'aadhaar'): ?>
                        <?php
                        $frontPath = $aadhaarPaths['front'] ?? null;
                        $backPath = $aadhaarPaths['back'] ?? null;
                        $singlePath = $aadhaarPaths['single'] ?? null;
                        $frontExists = (bool) resolve_upload_path($frontPath);
                        $backExists = (bool) resolve_upload_path($backPath);
                        $singleExists = (bool) resolve_upload_path($singlePath);
                        $status = $frontExists || $backExists || $singleExists ? 'Attached' : 'Missing';
                        ?>
                        <tr>
                            <td><?php echo e($doc['label']); ?></td>
                            <td><?php echo $status; ?></td>
                        </tr>
                        <?php if ($frontPath): ?>
                            <tr>
                                <td>&mdash; Aadhaar Front</td>
                                <td><?php echo $frontExists ? 'Attached' : 'Missing'; ?></td>
                            </tr>
                        <?php endif; ?>
                        <?php if ($backPath): ?>
                            <tr>
                                <td>&mdash; Aadhaar Back</td>
                                <td><?php echo $backExists ? 'Attached' : 'Missing'; ?></td>
                            </tr>
                        <?php endif; ?>
                        <?php continue; ?>
                    <?php endif; ?>
                    <?php $path = $emp[$doc['col']]; ?>
                    <?php $fileExists = (bool) resolve_upload_path($path); ?>
                    <tr>
                        <td><?php echo e($doc['label']); ?></td>
                        <td><?php echo $fileExists ? 'Attached' : 'Missing'; ?></td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        </section>

        <?php
        $availableDocs = [];
        foreach ($docs as $key => $doc) {
            if ($key === 'aadhaar') {
                $pairs = [
                    'aadhaar_front' => ['label' => 'Aadhaar Front', 'path' => $aadhaarPaths['front'] ?? null],
                    'aadhaar_back' => ['label' => 'Aadhaar Back', 'path' => $aadhaarPaths['back'] ?? null],
                    'aadhaar' => ['label' => $doc['label'], 'path' => $aadhaarPaths['single'] ?? null],
                ];
                foreach ($pairs as $typeKey => $info) {
                    $resolvedPath = resolve_upload_path($info['path'] ?? null);
                    if ($resolvedPath) {
                        $availableDocs[$typeKey] = [
                            'doc' => ['label' => $info['label']],
                            'path' => $info['path'],
                            'is_image' => is_image_file($resolvedPath),
                        ];
                    }
                }
                continue;
            }

            $path = $emp[$doc['col']];
            $resolvedPath = resolve_upload_path($path);
            if ($resolvedPath) {
                $availableDocs[$key] = [
                    'doc' => $doc,
                    'path' => $path,
                    'is_image' => is_image_file($resolvedPath),
                ];
            }
        }
        ?>

        <footer class="doc-footer">
            <div>This is a system-generated document.</div>
            <div class="page-number"></div>
        </footer>
    </div>

    <?php $availableKeys = array_keys($availableDocs); ?>
    <?php $lastKey = $availableKeys ? end($availableKeys) : null; ?>
    <?php foreach ($availableDocs as $key => $info): ?>
        <div class="attachment-block<?php echo $lastKey && $key !== $lastKey ? ' page-break' : ''; ?>">
            <div class="attachment-heading">Document: <?php echo e($info['doc']['label']); ?></div>
            <?php $src = 'download.php?id=' . $emp['id'] . '&type=' . $key . '&mode=inline'; ?>
            <?php if ($info['is_image']): ?>
                <img class="attachment-image" src="<?php echo $src; ?>" alt="<?php echo e($info['doc']['label']); ?>" />
            <?php else: ?>
                <object class="attachment-frame" data="<?php echo $src; ?>" type="application/pdf">
                    <p>Preview not available. <a href="<?php echo $src; ?>" target="_blank" rel="noreferrer">Open document</a></p>
                </object>
            <?php endif; ?>
        </div>
    <?php endforeach; ?>
</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