HEX
Server: nginx/1.24.0
System: Linux webserver-one 6.8.0-101-generic #101-Ubuntu SMP PREEMPT_DYNAMIC Mon Feb 9 10:15:05 UTC 2026 x86_64
User: www-data (33)
PHP: 8.4.18
Disabled: NONE
Upload Files
File: /srv/www/rectt-csmcri.res.in/public_html/pdf_tech.php
<?php
// session_start();
// ini_set("display_errors", 1);
// ini_set("display_startup_errors", 1);
// error_reporting(E_ALL);
include_once 'sites/config/config.php';

// $application_id = $_GET['application_id'];

function getTechSummaryHtml($application_id)
{
    global $conn;

    // Helper functions
    $fieldval = fn($v) => $v !== null && $v !== '' ? htmlspecialchars($v) : '<em>-</em>';
    $yesno = fn($v) => (strtolower($v) === 'yes') ? 'Yes' : 'No';
    $dateFormat = fn($d) => $d ? date('d-m-Y', strtotime($d)) : '<em>-</em>';

    // Fetch application
    $stmt = $conn->prepare("SELECT * FROM tech_applications WHERE id = ?");
    $stmt->bind_param("i", $application_id);
    $stmt->execute();
    $app = $stmt->get_result()->fetch_assoc();
    $stmt->close();

    if (!$app) return "<div style='color:#a00;text-align:center;margin-top:50px;'>No data found.</div>";

    // Determine exemption status from available fields
    $category = $_SESSION['category'] ?? 'General';
    $gender = $_SESSION['gender'] ?? '';
    $ex_servicemen = $_SESSION['ex_servicemen'] ?? '';
    $csir_employee = $_SESSION['csir_employee'] ?? '';
    $disability = $_SESSION['disability'] ?? 'No';

    $is_exempt = in_array($category, ['SC', 'ST']) ||
        $gender === 'Female' ||
        $ex_servicemen === 'Yes' ||
        $csir_employee === 'Yes' ||
        $disability === 'Yes';


    // Fetch qualifications
    $stmt = $conn->prepare("SELECT * FROM tech_qualifications WHERE application_id = ? ORDER BY FIELD(qualification_type, 'ssc', 'hsc', 'iti')");
    $stmt->bind_param("i", $application_id);
    $stmt->execute();
    $quals = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);
    $stmt->close();

    // Fetch trade details (should be only one row)
    $stmt = $conn->prepare("SELECT * FROM tech_trade_details WHERE application_id = ?");
    $stmt->bind_param("i", $application_id);
    $stmt->execute();
    $trade = $stmt->get_result()->fetch_assoc();
    $stmt->close();

    // Fetch experience
    $stmt = $conn->prepare("SELECT * FROM tech_experience WHERE application_id = ?");
    $stmt->bind_param("i", $application_id);
    $stmt->execute();
    $exps = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);
    $stmt->close();

    // Fetch uploads
    $uploads = [];
    $stmt = $conn->prepare("SELECT document_type, file_path FROM tech_uploads WHERE application_id = ?");
    $stmt->bind_param("i", $application_id);
    $stmt->execute();
    $res = $stmt->get_result();
    while ($row = $res->fetch_assoc()) $uploads[$row['document_type']] = $row['file_path'];
    $stmt->close();

    ob_start();
?>
    <!DOCTYPE html>
    <html lang="en">

    <head>
        <meta charset="UTF-8">
        <title>Technical Application Summary</title>
        <style>
            body {
                font-family: Arial, sans-serif;
                background: #fff;
                color: #222;
            }

            .main-table {
                width: 830px;
                margin: 0 auto 25px auto;
            }

            h2 {
                font-size: 16px;
                color: #333;
                font-weight: bold;
                margin: 40px 0 14px 0;
                text-align: left;
            }

            .qual-table,
            .trade-table,
            .exp-table,
            .upload-table {
                width: 100%;
                border-collapse: collapse;
                font-size: 13px;
                margin-bottom: 18px;
            }

            .qual-table th,
            .trade-table th,
            .exp-table th,
            .upload-table th {
                background: #fafafb;
                color: #555;
                font-weight: bold;
                padding: 8px 8px;
                border: 1px solid #e4e4e4;
            }

            .qual-table td,
            .trade-table td,
            .exp-table td,
            .upload-table td {
                padding: 8px 8px;
                border: 1px solid #e4e4e4;
            }

            .qual-table tr:last-child td,
            .trade-table tr:last-child td,
            .exp-table tr:last-child td,
            .upload-table tr:last-child td {
                border-bottom: none;
            }

            .not-uploaded {
                color: #b0b0b0;
                font-style: italic;
                text-align: center;
            }

            /* PHOTO & SIGNATURE TABLE */
            .photo-sign-table {
                width: 100%;
                margin: 30px 0 30px 0;
                border: none;
            }

            .photo-sign-label {
                font-size: 14px;
                font-weight: bold;
                color: #222;
                margin-bottom: 10px;
                display: block;
            }

            .photo-sign-img {
                width: 120px;
                height: auto;
                border: 2px solid #bbb;
                border-radius: 6px;
                background-color: #f9f9f9;
                margin: 0 auto 5px auto;
                display: block;
            }

            .sign-img {
                width: 100px;
                height: auto;
                border: 2px solid #bbb;
                border-radius: 6px;
                background-color: #f9f9f9;
                margin: 0 auto 5px auto;
                display: block;
            }

            .bottom-section {
                font-size: 13px;
                margin: 10px 0 25px 0;
            }

            .section-divider {
                border: none;
                border-top: 1px solid #ddd;
                margin: 28px 0;
            }

            .declaration-row {
                margin-top: 18px;
            }

            .checkbox-checked {
                display: inline-block;
                width: 13px;
                height: 13px;
                border: 1.7px solid #007e32;
                border-radius: 3px;
                background: #e7f7ea;
                text-align: center;
                vertical-align: middle;
            }

            .checkbox-checked-tick {
                font-size: 12px;
                color: #007e32;
                font-weight: bold;
                position: relative;
                top: -2px;
            }

            .declaration-text {
                color: #222;
                background: #f7f7f8;
                padding: 10px 15px;
                border-radius: 7px;
                display: inline-block;
                margin-left: 8px;
                font-size: 13px;
            }

            .right {
                text-align: right;
            }

            em {
                color: #888;
            }
        </style>
    </head>

    <body>
        <table class="main-table">
            <tr>
                <td>
                    <hr class="section-divider">
                    <h2>Educational Qualifications</h2>
                    <table class="qual-table">
                        <tr>
                            <th>Qualification</th>
                            <th>School/College</th>
                            <th>Board/University</th>
                            <th>Subjects Studies</th>
                            <th>Marks</th>
                            <th>Scale</th>
                            <th>Passing Date</th>
                            <th>Mode of Study</th>
                            <th>Remarks</th>
                        </tr>
                        <?php foreach ($quals as $q): ?>
                            <tr>
                                <td>
                                    <?php
                                    $type = strtolower($q['qualification_type']);
                                    switch ($type) {
                                        case 'ssc':
                                            echo '10/SSC';
                                            break;
                                        case 'hsc':
                                            echo '12/XII/Intermediate';
                                            break;
                                        case 'iti':
                                            echo 'ITI Qualification';
                                            break;
                                        default:
                                            echo $fieldval($q['qualification_type']);
                                    }
                                    ?>
                                </td>
                                <td><?= $fieldval($q['school_name']) ?></td>
                                <td><?= $fieldval($q['board_or_university']) ?></td>
                                <td><?= $fieldval($q['subjects']) ?></td>
                                <td><?= $fieldval($q['marks']) ?></td>
                                <td><?= $fieldval($q['scale']) ?></td>
                                <td><?= $dateFormat($q['pass_date']) ?></td>
                                <td><?= $fieldval($q['mode_of_study']) ?></td>
                                <td><?= $fieldval($q['remarks']) ?></td>
                            </tr>
                        <?php endforeach; ?>
                    </table>

                    <hr class="section-divider">

                    <h2>Trade Details</h2>
                    <table class="trade-table">
                        <tr>
                            <th>Trade Name</th>
                            <th>Trade Certificate</th>
                            <th>Trade Board/Institute/Organization (with address)</th>
                            <th>From</th>
                            <th>To</th>
                            <th>Year of Passing</th>
                            <th>Percentage</th>
                        </tr>
                        <?php if ($trade): ?>
                            <tr>
                                <td><?= $fieldval($trade['trade_name']) ?></td>
                                <td><?= $fieldval($trade['trade_certificate']) ?></td>
                                <td><?= $fieldval($trade['trade_board']) ?></td>
                                <td><?= $dateFormat($trade['from_date']) ?></td>
                                <td><?= $dateFormat($trade['to_date']) ?></td>
                                <td><?= $fieldval($trade['year_of_passing']) ?></td>
                                <td><?= $fieldval($trade['percentage']) ?></td>
                            </tr>
                        <?php else: ?>
                            <tr>
                                <td colspan="7" class="not-uploaded"><em>No trade details provided</em></td>
                            </tr>
                        <?php endif; ?>
                    </table>

                    <hr class="section-divider">

                    <h2>Employment / Experience</h2>
                    <table class="exp-table">
                        <tr>
                            <th>Type of the Organization</th>
                            <th>Name of the Organization</th>
                            <th>Position Held</th>
                            <th>From</th>
                            <th>To</th>
                            <th>Nature of Work</th>
                            <th>Last Pay Drawn</th>
                            <th>Status of Job</th>
                        </tr>
                        <?php if ($exps): foreach ($exps as $e): ?>
                                <tr>
                                    <td><?= $fieldval($e['org_type']) ?></td>
                                    <td><?= $fieldval($e['organization']) ?></td>
                                    <td><?= $fieldval($e['position']) ?></td>
                                    <td><?= $dateFormat($e['from_date']) ?></td>
                                    <td><?= $dateFormat($e['to_date']) ?></td>
                                    <td><?= $fieldval($e['nature_of_work']) ?></td>
                                    <td><?= $fieldval($e['last_pay']) ?></td>
                                    <td><?= $fieldval($e['job_status']) ?></td>
                                </tr>
                            <?php endforeach;
                        else: ?>
                            <tr>
                                <td colspan="8" class="not-uploaded"><em>No experience provided</em></td>
                            </tr>
                        <?php endif; ?>
                    </table>

                    <hr class="section-divider">

                    <h2>Uploaded Documents</h2>
                    <table class="upload-table">
                        <tr>
                            <th>Document Type</th>
                            <th>Uploaded</th>
                        </tr>
                        <?php foreach ($uploads as $type => $path): ?>
                            <?php if (!in_array($type, ['photograph', 'signature'])): ?>
                                <tr>
                                    <td>
                                        <?php
                                        $labels = [
                                            'ssc_marksheet'         => '10/SSC Marksheet',
                                            'hsc_marksheet'         => '12/XII/Intermediate Marksheet',
                                            'trade_certificate'     => 'Trade Certificate',
                                            'category_certificate'  => 'Category Certificate',
                                            'disability_certificate' => 'Disability Certificate',
                                        ];
                                        echo htmlspecialchars($labels[$type] ?? ucwords(str_replace('_', ' ', $type)), ENT_QUOTES, 'UTF-8');
                                        ?>
                                    </td>
                                    <td><?= $path ? 'Yes' : '<span class="not-uploaded">No</span>' ?></td>
                                </tr>
                            <?php endif; ?>
                        <?php endforeach; ?>
                    </table>

                    <hr class="section-divider">

                    <table class="photo-sign-table">
                        <tr>
                            <td align="center" valign="top">
                                <span class="photo-sign-label">Photograph</span><br>
                                <?php if (!empty($uploads['photograph'])): ?>
                                    <img class="photo-sign-img" src="<?= htmlspecialchars($uploads['photograph']) ?>">
                                <?php else: ?>
                                    <span class="not-uploaded">Not uploaded</span>
                                <?php endif; ?>
                            </td>
                            <td align="center" valign="top">
                                <span class="photo-sign-label">Signature</span><br>
                                <?php if (!empty($uploads['signature'])): ?>
                                    <img class="sign-img" src="<?= htmlspecialchars($uploads['signature']) ?>">
                                <?php else: ?>
                                    <span class="not-uploaded">Not uploaded</span>
                                <?php endif; ?>
                            </td>
                        </tr>
                    </table>

                    <hr class="section-divider">

                    <div class="bottom-section">
                        <div style="margin-bottom: 20px;">
                            <span style="font-weight:500;color:#444;">Additional Remarks: </span>
                            <?= $fieldval($app['additional_remarks']) ?>
                        </div>
                        <hr class="section-divider">
                        <div style="margin-bottom: 20px;">
                            <span style="font-weight:500;color:#444;">Payment Reference: </span>
                            <?= $fieldval($app['payment_reference_no']) ?>
                        </div>
                        <?php if (!$is_exempt): ?>
                            <div style="margin-bottom: 20px;">
                                <span style="font-weight:500;color:#444;">Payment Date: </span>
                                <?= $dateFormat($app['payment_date'] ?? '') ?>
                            </div>
                        <?php endif; ?>

                        <hr class="section-divider">
                        <div class="declaration-row">
                            <span class="checkbox-checked"><span class="checkbox-checked-tick">&#10003;</span></span>
                            <span class="declaration-text">
                                I, hereby, declare that all the statements made in this application are true, complete and correct to the best of my knowledge and belief.
                                In the event of any information being found false or incorrect or any ineligibility being detected before or after the selection, my candidature is liable to be cancelled and action can be initiated against me.
                            </span>
                        </div>
                        <div class="right" style="color:#555;font-size:1.02rem;margin-top:35px;">
                            <b>Submitted On:</b> <?= $dateFormat($app['created_at'] ?? '') ?>
                        </div>
                    </div>
                </td>
            </tr>
        </table>
    </body>

    </html>
<?php
    $data = ob_get_clean();
    return $data;
}
// $data = getTechSummaryHtml(6);
// // echo $data; // Or use as needed

?>