<?php
include "../config.php";
require_once "../fun/money_format.php";
$user_id = $_SESSION['user_id'];
$emp_id = $_SESSION['emp_id'];
$user_role = $_SESSION['user_role'];

if (!isset($_SESSION['emp_id'])) {
    echo "<script>location.href='../index';</script>";
}

function AmountInWords(float $amount)
{
    $amount_after_decimal = round($amount - ($num = floor($amount)), 2) * 100;
    // Check if there is any number after decimal
    $amt_hundred = null;
    $count_length = strlen($num);
    $x = 0;
    $string = array();
    $change_words = array(
        0 => '', 1 => 'One', 2 => 'Two',
        3 => 'Three', 4 => 'Four', 5 => 'Five', 6 => 'Six',
        7 => 'Seven', 8 => 'Eight', 9 => 'Nine',
        10 => 'Ten', 11 => 'Eleven', 12 => 'Twelve',
        13 => 'Thirteen', 14 => 'Fourteen', 15 => 'Fifteen',
        16 => 'Sixteen', 17 => 'Seventeen', 18 => 'Eighteen',
        19 => 'Nineteen', 20 => 'Twenty', 30 => 'Thirty',
        40 => 'Forty', 50 => 'Fifty', 60 => 'Sixty',
        70 => 'Seventy', 80 => 'Eighty', 90 => 'Ninety'
    );
    $here_digits = array('', 'Hundred', 'Thousand', 'Lakh', 'Crore');

    while ($x < $count_length) {
        $get_divider = ($x == 2) ? 10 : 100;
        $amount = floor($num % $get_divider);
        $num = floor($num / $get_divider);
        $x += $get_divider == 10 ? 1 : 2;

        if ($amount) {
            $add_plural = (($counter = count($string)) && $amount > 9) ? 's' : null;
            $amt_hundred = ($counter == 1 && $string[0]) ? ' and ' : null;
            $string[] = ($amount < 21) ? $change_words[$amount] . ' ' . $here_digits[$counter] . $add_plural . ' 
                ' . $amt_hundred : $change_words[floor($amount / 10) * 10] . ' ' . $change_words[$amount % 10] . ' 
                ' . $here_digits[$counter] . $add_plural . ' ' . $amt_hundred;
        } else {
            $string[] = null;
        }
    }
    $implode_to_Rupees = implode('', array_reverse($string));
    $get_paise = ($amount_after_decimal > 0) ? "And " . ($change_words[$amount_after_decimal / 10] . " 
        " . $change_words[$amount_after_decimal % 10]) . ' Paise' : '';
    return ($implode_to_Rupees ? $implode_to_Rupees . 'Rupees ' : '') . $get_paise;
}


$id = mysqli_real_escape_string($db, base64_decode($_GET['id']));
$data = mysqli_fetch_assoc(mysqli_query($db, "SELECT * FROM full_time_letter WHERE id='$id'"));

####################################################################
$approved_by = json_decode($data['approved_by'], true);
$is_all_approved = false;

$approvals = !empty($data['approved_by']) ? json_decode($data['approved_by'], true) : [];
if (!empty($approvals)) {
    $lastSubarray = end($approvals);
    $lastStatuses = is_array($lastSubarray) ? array_column($lastSubarray, 'status') : [];
} else {
    $lastStatuses = [];
}
$is_all_approved = count(array_filter($lastStatuses, fn($val) => $val == 1)) === count($lastStatuses);
if ($user_role!=0 && (empty($lastStatuses) || !$is_all_approved)){
    // add watermark
    echo "<style>
        .watermark {
            position: fixed;
            top: 50%;
            left: 50%;
            width: fit-content;
            transform: translate(-50%, -50%) rotate(45deg);
            font-size: 60px;
            display: none;
            color: rgba(0, 0, 0, 0.2);
            pointer-events: none;
            display: none;
            mix-blend-mode: darken;
        }
    </style>

    <div class=\"watermark\"><img src='{$url}/letters/unathorized.png'></div>

    <script>
        // JavaScript to control printing
        window.onload = function() {
            document.querySelector('.watermark').style.display = 'none'; // Hide watermark on the screen

            // Show watermark on every printed page
            window.onbeforeprint = function() {
                document.querySelector('.watermark').style.display = 'block';
            };

            // Hide watermark after printing is done
            window.onafterprint = function() {
                document.querySelector('.watermark').style.display = 'none';
            };
        };
    </script>";
}
####################################################################
if(($_SESSION['emp_id']=='NI406' && !$is_all_approved)){
    echo "<script>location.href='../404';</script>";
}

if ($_SESSION['emp_id']!='NI406' && ($_SESSION['user_role'] != 0 && $data['added_by']!=$_SESSION['emp_id'] && !isset($lastSubarray[$_SESSION['emp_id']]) )) {
    echo "<script>location.href='../404';</script>";
}

$total_per_month = round($data['basic_salary'] / 12) + round($data['hra'] / 12) + round($data['sp_allowance'] / 12) + round($data['books_per'] / 12) + round($data['retention_bonus'] / 12);
$total_per_annum = $data['basic_salary'] + $data['hra'] + $data['sp_allowance'] + $data['books_per'] + $data['retention_bonus'];

$for_deduction_month = $total_per_month;
$for_deduction_annum = $total_per_annum;

$addOn = json_decode($data['add-on'], true);
$deduction = json_decode($data['deduction'], true);

$date1 = date_create("$data[joining_date]");
$date2 = date_create("$data[probation_date]");
$diff = date_diff($date1, $date2);
$probation_month = $diff->m . ' Month(s)';

?>
<!doctype html>
<html lang="en">

<head>
    <meta charset="utf8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/png" href="https://www.jobaaj.com/images/">

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    <title>Offer Letter</title>
    <style>
        * {
            font-size: 13px;
        }

        /* @page { size: auto;  margin: 0mm; } */
        @media print {
            @page {
                margin-left: 0.6in;
                margin-right: 0.6in;
                margin-top: 0.3in;
                margin-bottom: 0.3in;
            }
        }

        table.report-container {
            page-break-after: always;
        }

        thead.report-header {
            display: table-header-group;
        }

        tfoot.report-footer {
            display: table-footer-group;
        }
    </style>
</head>

<body>
    <table class="report-container container" style="border:2px solid black;padding:2rem;margin-top:1rem;margin-bottom:9rem;">
        <thead class="report-header">
            <tr>
                <th class="report-header-cell mt-1 p-1 mb-1">
                    <div class="header-info m-3 mb-1">
                        <div class="d-flex flex-row">
                            <span><img src="<?php echo $url; ?>/letters/nishtya_transparent.png" style="width:6rem" alt=""></span>
                            <div style="margin-left: 1rem;">
                                <h3 class="fw-bold mb-1">NISHTYA INFOTECH PVT. LTD </h3>
                                <p class="text-right"> 379, Vardhman Grand Plaza, Plot No.7, <br>
                                    Manglam Place, Sector-3, Rohini <br>
                                    New Delhi- 110085 <br>
                                </p>
                            </div>
                            <span><img src="<?php echo $url; ?>/letters/1.png" style="width:6rem;margin-left:6rem;" alt=""></span>
                        </div>
                    </div>
                    </div>

                </th>
            </tr>
        </thead>
        <tfoot class="report-footer">
            <tr>
                <td class="report-footer-cell">
                    <div class="footer-info p-2">
                        <div class="d-flex flex-row" style="justify-content: space-between;">
                            <p>
                                <i class="fa-sharp fa-solid fa-tty"></i> Tel: 0562-4306559 &nbsp; <br>
                                <i class="fa-solid fa-phone"></i> 073035 12500 &nbsp; <br>
                                <i class="fa-solid fa-envelope"></i> contact@nishtyainfotech.com &nbsp;
                            </p>
                            <p style="text-align: right">
                                <i class="fa-solid fa-location-dot"></i> Registered Office: 379, Vardhman Grand Plaza, Plot No.7, <br>
                                &nbsp;&nbsp;&nbsp; Manglam Place, Sector-3, Rohini, New Delhi 110085 <br>
                                <i class="fa-sharp fa-solid fa-globe"></i> URL:https://nishtyainfotech.com
                            </p>
                        </div>
                    </div>
                </td>
            </tr>
        </tfoot>
        <tbody class="report-content">
            <tr>
                <td class="report-content-cell">
                    <div class="main p-3">
                        <p class="mb-2"><?php echo date("d-M-Y", strtotime($data['issue_date'])); ?></p>
                        <p class="mb-2">To <?php echo $data['first_name'] . ' ' . $data['last_name']; ?></p>

                        <p class="fw-bold mb-2" style="text-align: center;">Letter of Appointment</p>

                        <p class="mb-2">Dear <?php echo $data['first_name']; ?></p>

                        <h6 class="lh-base mb-2"> We are pleased to appoint you for the <strong>"<?php echo $data['position']; ?>"</strong> position at Nishtya Infotech Private
                            Limited. The following terms and conditions will be applicable.</h6>

                        <ol>
                            <li>SALARY & ALLOWANCE: You will be entitled to Gross salary per the attached Annexure.</li>
                            <li>EFFECTIVE DATE OF APPOINTMENT: Your actual date of joining i.e. <?php echo date("d-M-Y", strtotime($data['joining_date'])); ?> shall be deemed
                                as your effective date of appointment.</li>
                            <li>PLACE OF POSTING: You will be part of our company office in Agra, but will serve the company, its
                                subsidiaries, or associated companies in any location.</li>
                            <li>PROBATION: You will be on probation for a period of <?php echo $probation_month; ?>. Your confirmation will be subject
                                to satisfactory performance during the probationary period.</li>
                            <li>TRANSFER: You may be liable to be transferred from one department to another, one section to
                                another, one branch to another, one establishment to another, or any of its associate companies, in India,
                                either existing today or to be started at any time after your employment.</li>
                            <li>FULL-TIME EMPLOYMENT: This is Full -time employment, and therefore you shall devote
                                respective time to the work of the company and will not undertake any direct/indirect business or work,
                                honorary or remunerator, except with prior written permission of the Management, in each case.</li>
                            <li>CONFIDENTIALITY/SECRECY: During the term of your appointment and for at least two(2) years
                                after its termination, you shall not disclose, divulge to anyone by word of mouth or otherwise the content
                                of this offer letter, particular or detail of products, developing process, technical knowhow,
                                administrative or organizational matters, proprietary information about the company either directly or
                                indirectly, which may be your privilege to know by being in the employment of the company. You will
                                also maintain complete confidentiality concerning client data and information, whether acquired during
                                the course of the company's business dealings or otherwise. Any contravention/transgression of the strict
                                confidentiality conditions of this Section 7 will render you liable to summary dismissal and /or
                                prosecution for criminal breach of trust and any other cause of action available under Indian law. You
                                must not at any time after leaving the employment of the Company, for any reason, disclose or permit to
                                be disclosed to any person, firm, company, or other entity other than Nishtya Infotech Private Limited
                                any confidential, technical, or sensitive information or trade secrets relating to or belonging to Nishtya
                                Infotech Private Limited or its affiliates, You are also expected to keep confidential all sensitive data that
                                you may have in your possession and about your ex-employer.</li>
                            <li>MEDICAL FITNESS: This appointment and its continuance are subject to your being found &
                                remaining in sound physical and mental health. As and when required you shall report for any medical
                                examination to a qualified doctor as recommended /appointed by the company.</li>
                            <li>RESIDENTIAL ADDRESS: Your address as given in the application form will be deemed to be correct
                                for the purpose of sending any communication to you. In case of any change in your address, you will
                                inform the management about the same, in writing.</li>
                            <li>NON-SOLICIT/COMPETITION: During the term of your employment with the company, and for a
                                period of two years after the termination thereof (whether by yourself or the company) you will not act
                                as a consultant for clients of Nishtya Infotech Private Limited or Deal with these clients by virtue of
                                your employment somewhere else, and will not be in any way in contact with clients of Jobaaj Group
                                (Nishtya Infotech Private Limited).</li>
                            <li>TERMINATION: In case you decide to leave the service of the organization, you will be required to
                                give notice as per company policy. For all company associates, the notice period is <?php echo $data['notice_period']; ?> days. The
                                organization in its sole discretion can decide to reduce the notice period depending upon the exigencies.
                                In such a case, you would be required to pay the notice period recovery amount for the notice period so
                                reduced. In case the organization decides to terminate your employment services, It will give notice as
                                per company policy. Notwithstanding any other provision, hereof, your employment may be terminated
                                by the company without notice or without payment in lieu of notice if it has reasonable grounds to
                                believe that you are guilty of misconduct or negligence, or have committed any breach of terms of this
                                letter of appointment or have violated any of the applicable policies that the employees of the company
                                are expected to adhere to.</li>
                            <li>In the event of you leaving the company within 12 months of your joining, any payment made to you on
                                account of either notice period buyout or joining bonus needs to be returned to the company in gross.</li>
                            <li>RETIREMENT AGE: You will retire from the services of the company at the age of 58 years or the last
                                day before that, in case that day does not fall on a working day. The official record of your date of birth
                                with the company shall be considered for the purpose of calculating your age.</li>
                            <li>Please ensure that all the documents submitted by you and the details provided in the company
                                application forms are authentic and accurate. In the event the said particulars are found to be incorrect or
                                that you have withheld some other relevant facts, your appointment in the company shall stand canceled
                                without any notice. Your appointment and continuance in employment are also subject to the satisfactory
                                outcome of required checks that may be conducted either before or after the date at which full-time
                                employment commences. Such checks may or may not include any or all of the following: (i)
                                background checks (including checking all facts submitted to the company, including, but not limited to
                                your curriculum vitae or application); (ii) reference checks; (iii) fingerprinting; (iv) drug testing; (v)
                                medical examination(s) as determined to be relevant by the company.</li>
                            <li>INVENTIONS AND PUBLICATIONS: Any inventions, designs or improvements, reports, manuals,
                                papers, or any other form of the publication containing information relating to the products or services of
                                the company you may produce or formulate or with which you are concerned during your employment
                                shall be freely communicated to the company and shall be and remain the property of the company, free
                                of charge. You will be required, on the request of the company, to take such steps as are necessary to
                                obtain protection for any invention, copyright, design, or other matters mentioned in this Section and in
                                order to vest them in the company.</li>
                            <!-- <li>LEAVE: Each employee of the company will be entitled to have 1.5 Paid Leave every Month, which
                                needs to be communicated 1 Day prior and are subject to approval by your Reporting Managers.
                                Unutilized paid leaves during any month shall not roll over to the next month and will lapse after the end
                                of the respective months. No Employee can utilize more than 1.5 Paid Leave in any month at any point
                                in time.</li> -->
                            <li>LEAVE: Team members have the option to carry forward and accumulate their leaves within certain limits.<br>
                                1. For the financial year, they are entitled to 12 Casual Leaves and 6 Medical Leaves. When using their leaves, they can take a maximum of 3 days at a time, and these cannot be combined with weekends or holidays unless approved by their managers.
                                <br>2. Unutilized leaves can be encashed, but the maximum encashment allowed is 4 days.
                                <br>3. Additionally, team members can carry forward a maximum of 4 days of leaves to the next year, any unused leaves beyond this limit on 31st March will not be carried forward and will be forfeited.</li>
                            <li>DOCUMENTS: On the day of reporting, you are required to bring the following documents for our
                                records. Your appointment is valid subject to the submission of these documents.</li>
                            <ul>
                                <li>Relieving letter from the last employer / Resignation acceptance letter.</li>
                                <li>2 recent Passport size photographs.</li>
                                <li>All your Academic Records Hard and 2 Softcopy</li>
                            </ul>
                        </ol>
                        You shall conduct all activities under this appointment in accordance with sound business practices and
                        ethics and in a manner which reflects favorably upon the company and its products and the goodwill
                        associate herewith. <br><br>
                        The terms of your employment with the company may be revised as per the prevailing policies of the
                        company with prior notice to you. <br><br>
                        The appointment will be governed by the Indian Laws and be subjected to the jurisdiction of Delhi Courts. <br>
                        Please submit to us the written acceptance of this offer by signing the second copy of this letter. <br><br>
                        We welcome you to Nishtya Infotech Private Ltd and look forward to your continued growth with us. We are
                        sure you will enjoy being part of the team. <br><br>
                        Yours sincerely, <br>
                        <span><img src="<?php echo $url; ?>/letters/akhilesh_sign.jpeg" style="width:8rem; mix-blend-mode: hard-light;" alt=""></span><br>
                        Akhilesh Kumar Saha <br>
                        Authorized Signatory <br>
                        Snr. Finance Manager <br>
                        <strong>Nishtya Infotech Pvt. Ltd.</strong>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>

    <table class="report-container container">

        <thead class="report-header">
            <tr>
                <th class="report-header-cell p-1 mb-0">
                    <div class="header-info m-3 mb-0">
                        <div class="d-flex justify-content-between mb-0">
                            <div class=""> <i class="fa-solid fa-phone"></i>&nbsp;+91 73035 12500</div>
                            <div class=""><i class="fa-sharp fa-solid fa-globe"></i>&nbsp;www.nishtyainfotech.com</div>
                            <div class=""><i class="fa-solid fa-envelope"></i>&nbsp;contact@nishtyainfotech.com</div>
                        </div>
                        <div class="d-flex flex-row">
                            <span><img src="<?php echo $url; ?>/letters/nishtya_transparent.png" style="width:5rem" alt=""></span>
                            <div style="margin-left: 1rem;">
                                <p class="h1 fw-bold mb-1">NISHTYA INFOTECH PVT. LTD </p>
                                <p class="text-right"> 379, Vardhman Grand Plaza, Plot No.7, <br>
                                    Manglam Place, Sector-3, Rohini <br>
                                    New Delhi- 110085 <br>
                                </p>
                            </div>
                            <span><img src="<?php echo $url; ?>/letters/1.png" style="width:6rem;margin-left:8rem;" alt=""></span>
                        </div>
                    </div>
                </th>
            </tr>
        </thead>

        <tbody class="report-content">
            <tr>
                <td class="report-content-cell">
                    <div class="main p-3 pt-0">
                        <h6 style="text-align: center;">Annexure I</h6>
                        <table>
                            <tr>
                                <th>Name of Employee</th>
                                <td> : <?php echo $data['first_name'] . ' ' . $data['last_name']; ?></td>

                            </tr>
                            <tr>
                                <th>Designation</th>
                                <td> : <?php echo $data['position']; ?></td>
                            </tr>
                            <tr>
                                <th>Date of Joining</th>
                                <td class="mb-0"> : <?php echo date("d-M-Y", strtotime($data['joining_date'])); ?></td>
                            </tr>
                            <tr>
                                <th>Location</th>
                                <td> : Agra</td>

                            </tr>
                            <tr>
                                <th>Level</th>
                                <td> : <?php echo $data['level']; ?></td>
                            </tr>
                        </table>

                        <table class="mt-2" style="width:100%; border: 1px solid black;">

                            <tr>
                                <th style="border: 1px solid black;border-collapse: collapse;text-align: center;">Particular/Component</th>
                                <th style="border: 1px solid black;border-collapse: collapse;text-align: center;">Per Month &#8377;</th>
                                <th style="border: 1px solid black;border-collapse: collapse;text-align: center;">Per Annum &#8377;</th>
                            </tr>

                            <tr>
                                <td style="border: 1px solid black;border-collapse: collapse;text-align: left;font-weight:bold;">Fixed Pay</td>
                                <td style="border: 1px solid black;border-collapse: collapse;text-align: center;"></td>
                                <td style="border: 1px solid black;border-collapse: collapse;text-align: center;"></td>
                            </tr>
                            <tr>
                                <td style="border: 1px solid black;border-collapse: collapse;text-align: left;">&nbsp;&nbsp;Basic Salary</td>
                                <td style="border: 1px solid black;border-collapse: collapse;text-align: center;"><?php echo IND_money_format(round($data['basic_salary'] / 12)); ?> </td>
                                <td style="border: 1px solid black;border-collapse: collapse;text-align: center;"><?php echo IND_money_format($data['basic_salary']); ?></td>
                            </tr>
                            <tr>
                                <td style="border: 1px solid black;border-collapse: collapse;text-align: left;">&nbsp;&nbsp;House Rent Allowance</td>
                                <td style="border: 1px solid black;border-collapse: collapse;text-align: center;"><?php echo IND_money_format(round($data['hra'] / 12)); ?></td>
                                <td style="border: 1px solid black;border-collapse: collapse;text-align: center;"><?php echo IND_money_format($data['hra']); ?></td>
                            </tr>
                            <tr>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: left;">&nbsp;&nbsp;Special Allowance</td>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"><?php echo IND_money_format(round($data['sp_allowance'] / 12)); ?></td>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"><?php echo IND_money_format($data['sp_allowance']); ?></td>
                            </tr>
                            <tr>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: left;">&nbsp;&nbsp;Books & Periodicals </td>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"><?php echo IND_money_format(round($data['books_per'] / 12)); ?></td>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"><?php echo IND_money_format($data['books_per']); ?></td>
                            </tr>
                            <tr>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: left;">&nbsp;&nbsp;Retention Bonus </td>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"><?php echo IND_money_format(round($data['retention_bonus'] / 12)); ?></td>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"><?php echo IND_money_format($data['retention_bonus']); ?></td>
                            </tr>

                            <tr>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: left;font-weight:bold;">Total Fixed Salary (A)</td>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"><?php echo IND_money_format($total_per_month); ?></td>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"><?php echo IND_money_format($total_per_annum); ?></td>
                            </tr>
                            <?php
                            $addOn_month = 0;
                            $addOn_annum = 0;
                            foreach ($addOn as $key => $value) {
                                if (!empty($key)) {
                            ?>
                                    <tr>
                                        <?php if (strtolower($key) == "variable pay") { ?>
                                            <td style="border: 1px solid black;border-collapse: collapse; text-align: left; font-weight:bold;"><?php echo $key; ?></td>
                                        <?php } else { ?>
                                            <td style="border: 1px solid black;border-collapse: collapse; text-align: left;">&nbsp;&nbsp;<?php echo $key; ?></td>
                                        <?php } ?>

                                        <td style="border: 1px solid black;border-collapse: collapse; text-align: center;">
                                            <?php echo is_numeric($value) ? IND_money_format(round($value / 12)) : $value; ?>
                                        </td>

                                        <td style="border: 1px solid black;border-collapse: collapse; text-align: center;">
                                            <?php echo is_numeric($value) ? IND_money_format(round($value)) : $value; ?>
                                        </td>
                                    </tr>
                            <?php
                                    $total_per_month += round($value / 12);
                                    $total_per_annum += round($value);
                                }
                            } ?>

                            <tr>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: left;font-weight:bold;">Total Gross CTC* (Excluding Incentives)</td>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"> <?php echo IND_money_format($total_per_month); ?></td>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"><?php echo IND_money_format($total_per_annum); ?></td>
                            </tr>

                            <?php
                            foreach ($deduction as $key => $value) {
                                if (!empty($key)) {
                            ?>
                                    <tr>
                                        <td style="border: 1px solid black;border-collapse: collapse;text-align: left;font-weight:bold;">Deduction (B)</td>
                                        <td style="border: 1px solid black;border-collapse: collapse;text-align: center;"></td>
                                        <td style="border: 1px solid black;border-collapse: collapse;text-align: center;"></td>
                                    </tr>
                                <?php
                                    break;
                                }
                            }
                            $deduction_month = 0;
                            $deduction_annum = 0;
                            foreach ($deduction as $key => $value) {
                                if (!empty($key)) {
                                ?>
                                    <tr>
                                        <td style="border: 1px solid black;border-collapse: collapse; text-align: left;">&nbsp;&nbsp;<?php echo $key; ?></td>
                                        <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"> <?php echo IND_money_format(round($value / 12)); ?></td>
                                        <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"><?php echo IND_money_format($value); ?></td>

                                        <?php
                                        $deduction_month += round($value / 12);
                                        $deduction_annum += $value;
                                        ?>
                                    </tr>
                            <?php }
                            } ?>

                            <tr>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: left;font-weight:bold">
                                    <?php if ($deduction_month != 0) { ?>
                                        Net Pay (A-B)
                                    <?php } else { ?>
                                        Net Pay (A)
                                    <?php } ?>
                                </td>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"> <?php echo IND_money_format($for_deduction_month -  $deduction_month); ?></td>
                                <td style="border: 1px solid black;border-collapse: collapse; text-align: center;"><?php echo IND_money_format($for_deduction_annum -  $deduction_annum); ?></td>
                            </tr>
                        </table>

                        <?php if (!empty($data['incentive_term'])) { ?>
                            <h6 class="mt-2 mb-0">Performance Incentive^^</h6>
                            <span class="mb-0" id="spaceDIV"><?php echo $data['incentive_term']; ?></span>
                        <?php } ?>

                        <h6 class="mt-2 mb-0">Total CTC*</h6>
                        <ul>
                            <li> Total Cost to Company is a total of Gross Annual Fixed and Annual Variable Pay plus Annual Bonus at 100%
                                payout as per the clause mentioned above.</li>
                            <li> PF,ESI, Income Tax, and Local Tax will be deducted as per the prevailing rules.(If applicable) <br>
                                For Nishtya Infotech Pvt. Ltd.</li>
                        </ul>

                        <span><img src="<?php echo $url; ?>/letters/akhilesh_sign.jpeg" style="width:8rem; mix-blend-mode: hard-light;" alt=""></span><br>
                        Akhilesh Kumar Saha <br>
                        Authorized Signatory <br>
                        Snr. Finance Manager <br>
                        <strong>Nishtya Infotech Pvt. Ltd.</strong>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>

    <script>
        let numb = document.getElementById("spaceDIV").childElementCount;
        const collection = document.getElementById("spaceDIV").children;
        for (let i = 0; i < numb; i++) {
            collection[i].style.marginBottom = "0px";
        }
    </script>

</body>
<script>
    window.print();
</script>
<script>
    document.addEventListener("contextmenu", (event) => {
        event.preventDefault();
    });
    document.addEventListener('keydown', function(e) {
        // F12
        if (e.keyCode === 123) {
            e.preventDefault();
        }

        // Block Ctrl+Shift+I / J / C
        if (e.ctrlKey && e.shiftKey && ['I', 'i', 'J', 'j', 'C', 'c'].includes(e.key)) {
            e.preventDefault();
            return false;
        }

        // Block Ctrl+U
        if (e.ctrlKey && ['U', 'u'].includes(e.key)) {
            e.preventDefault();
            return false;
        }
    });

    setInterval(() => {
        const before = new Date().getTime();
        debugger;
        const after = new Date().getTime();
        if (after - before > 100) {
            document.body.innerHTML = "<h1 style='color:red;text-align:center;margin-top:20%'>Unauthorized Access Detected. Closing Page...</h1>";
            setTimeout(() => {
                window.location.href = "about:blank"; // or just hang the page
            }, 2000);
        }
    }, 100);
</script>
</html>