<!DOCTYPE html>
<html>
<head>
    <title><?= lang('jobs_posted') ?></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <?php
    $direction = $this->session->userdata('direction');
    if (!empty($direction) && $direction == 'rtl') {
        $RTL = 'on';
    } else {
        $RTL = config_item('RTL');
    }

    $text_align = !empty($RTL) ? 'right' : 'left';
    $opposite_align = !empty($RTL) ? 'left' : 'right';

    $designation = '-';
    if (!empty($job_posted->designations_id)) {
        $design_info = $this->db->where('designations_id', $job_posted->designations_id)->get('tbl_designations')->row();
        $designation = !empty($design_info->designations) ? $design_info->designations : '-';
    }
    ?>
    <style type="text/css">
        body {
            margin: 0;
            color: #1e293b;
            font-family: DejaVu Sans, Arial, Helvetica, sans-serif;
            font-size: 11px;
            line-height: 1.45;
            background: #ffffff;
        }

        .page {
            padding: 20px 24px 24px;
        }

        .report-header {
            border-bottom: 2px solid #2563eb;
            padding-bottom: 12px;
            margin-bottom: 14px;
        }

        .report-header table,
        .summary-table,
        .details-table {
            width: 100%;
            border-collapse: collapse;
        }

        .logo-cell {
            width: 58px;
            vertical-align: middle;
        }

        .logo {
            width: 46px;
            max-height: 46px;
        }

        .company-name {
            font-size: 20px;
            font-weight: bold;
            color: #0f172a;
            margin: 0 0 2px;
            text-align: <?= $text_align ?>;
        }

        .report-kicker {
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 0.8px;
            color: #2563eb;
            margin: 0 0 2px;
            text-align: <?= $text_align ?>;
        }

        .report-title {
            font-size: 14px;
            font-weight: bold;
            color: #334155;
            margin: 0;
            text-align: <?= $text_align ?>;
        }

        .meta-cell {
            width: 150px;
            vertical-align: middle;
            text-align: <?= $opposite_align ?>;
        }

        .meta-box {
            display: inline-block;
            background: #f8fafc;
            padding: 7px 10px;
            text-align: <?= $text_align ?>;
        }

        .meta-label {
            color: #64748b;
            font-size: 9px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin: 0 0 2px;
        }

        .meta-value {
            color: #0f172a;
            font-size: 11px;
            font-weight: bold;
            margin: 0;
        }

        .summary-wrap {
            border: 1px solid #dbe4ee;
            margin-bottom: 14px;
        }

        .summary-label {
            font-size: 9px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            color: #64748b;
            padding: 10px 12px 2px;
            text-align: <?= $text_align ?>;
        }

        .summary-value {
            font-size: 13px;
            color: #0f172a;
            font-weight: bold;
            padding: 0 12px 10px;
            text-align: <?= $text_align ?>;
        }

        .summary-cell {
            width: 50%;
            border-right: 1px solid #dbe4ee;
        }

        .summary-cell-last {
            border-right: 0;
        }

        .section {
            margin-bottom: 15px;
        }

        .section-title {
            color: #0f172a;
            font-size: 13px;
            font-weight: bold;
            padding: 0 0 7px;
            border-bottom: 1px solid #dbe4ee;
            margin-bottom: 8px;
        }

        .details-table {
            table-layout: fixed;
        }

        .details-table td {
            border: 1px solid #dbe4ee;
            padding: 8px 10px;
            vertical-align: top;
            text-align: <?= $text_align ?>;
        }

        .details-table tr:nth-child(even) td {
            background: #f8fafc;
        }

        .label-cell {
            width: 28%;
            color: #64748b;
            font-size: 10px;
            font-weight: bold;
            text-transform: uppercase;
            letter-spacing: 0.4px;
        }

        .value-cell {
            color: #0f172a;
            font-size: 11px;
            font-weight: bold;
        }

        .description-box {
            border: 1px solid #dbe4ee;
            background: #f8fafc;
            padding: 12px;
            color: #334155;
            font-size: 11px;
            line-height: 1.55;
            text-align: <?= $text_align ?>;
        }

        .footer-note {
            border-top: 1px solid #e2e8f0;
            padding-top: 8px;
            margin-top: 16px;
            color: #94a3b8;
            font-size: 9px;
            text-align: <?= $opposite_align ?>;
        }
    </style>
</head>
<body>
<?php
$img = ROOTPATH . '/' . config_item('company_logo');
$a = file_exists($img);
if (empty($a)) {
    $img = base_url() . config_item('company_logo');
}
if (!file_exists($img)) {
    $img = ROOTPATH . '/' . 'uploads/default_logo.png';
}

$job_title = !empty($job_posted->job_title) ? $job_posted->job_title : '-';
$posted_date = !empty($job_posted->posted_date) ? display_date($job_posted->posted_date) : '-';
$last_date = !empty($job_posted->last_date) ? display_date($job_posted->last_date) : '-';
?>
<div class="page">
    <div class="report-header">
        <table>
            <tr>
                <td class="logo-cell">
                    <img class="logo" src="<?= $img ?>" alt="<?= config_item('company_name') ?>">
                </td>
                <td>
                    <p class="report-kicker"><?= lang('jobs_posted') ?></p>
                    <p class="company-name"><?= config_item('company_name') ?></p>
                    <p class="report-title"><?= lang('view_circular_details') ?></p>
                </td>
                <td class="meta-cell">
                    <div class="meta-box">
                        <p class="meta-label"><?= lang('posted_date') ?></p>
                        <p class="meta-value"><?= $posted_date ?></p>
                    </div>
                </td>
            </tr>
        </table>
    </div>

    <div class="summary-wrap">
        <table class="summary-table">
            <tr>
                <td class="summary-cell">
                    <div class="summary-label"><?= lang('job_title') ?></div>
                    <div class="summary-value"><?= html_escape($job_title) ?></div>
                </td>
                <td class="summary-cell summary-cell-last">
                    <div class="summary-label"><?= lang('last_date_to_apply') ?></div>
                    <div class="summary-value"><?= $last_date ?></div>
                </td>
            </tr>
        </table>
    </div>

    <div class="section">
        <div class="section-title"><?= lang('view_circular_details') ?></div>
        <table class="details-table">
            <tr>
                <td class="label-cell"><?= lang('designation') ?></td>
                <td class="value-cell"><?= html_escape($designation) ?></td>
            </tr>
            <tr>
                <td class="label-cell"><?= lang('experience') ?></td>
                <td class="value-cell"><?= html_escape(!empty($job_posted->experience) ? $job_posted->experience : '-') ?></td>
            </tr>
            <tr>
                <td class="label-cell"><?= lang('age') ?></td>
                <td class="value-cell"><?= html_escape(!empty($job_posted->age) ? $job_posted->age : '-') ?></td>
            </tr>
            <tr>
                <td class="label-cell"><?= lang('salary_range') ?></td>
                <td class="value-cell"><?= html_escape(!empty($job_posted->salary_range) ? $job_posted->salary_range : '-') ?></td>
            </tr>
            <tr>
                <td class="label-cell"><?= lang('vacancy_no') ?></td>
                <td class="value-cell"><?= html_escape(!empty($job_posted->vacancy_no) ? $job_posted->vacancy_no : '-') ?></td>
            </tr>
            <tr>
                <td class="label-cell"><?= lang('posted_date') ?></td>
                <td class="value-cell"><?= $posted_date ?></td>
            </tr>
            <tr>
                <td class="label-cell"><?= lang('last_date_to_apply') ?></td>
                <td class="value-cell"><?= $last_date ?></td>
            </tr>
            <?php
            $show_custom_fields = custom_form_label(14, $job_posted->job_circular_id);
            if (!empty($show_custom_fields)) {
                foreach ($show_custom_fields as $c_label => $v_fields) {
                    if (!empty($v_fields)) {
                        ?>
                        <tr>
                            <td class="label-cell"><?= html_escape($c_label) ?></td>
                            <td class="value-cell"><?= strip_html_tags($v_fields, true) ?></td>
                        </tr>
                    <?php }
                }
            }
            ?>
        </table>
    </div>

    <div class="section">
        <div class="section-title"><?= lang('description') ?></div>
        <div class="description-box">
            <?= !empty($job_posted->description) ? strip_html_tags($job_posted->description, true) : '-' ?>
        </div>
    </div>

    <div class="footer-note">
        <?= config_item('company_name') ?> &middot; <?= lang('jobs_posted') ?>
    </div>
</div>
</body>
</html>
