<style>
    @page {
        margin: 28px 34px 28px 34px;
    }

    <?php
    if (!function_exists('app_font_pdf')) {
        $this->load->helper('settings');
    }
    $so_pdf_font = app_font_pdf();
    $signatory_html = function_exists('app_document_signatory_html') ? app_document_signatory_html() : '';
    $signatory_attn = function_exists('app_document_signatory_attn') ? app_document_signatory_attn() : '';
    ?>

    @font-face {
        font-family: 'NotoSansDevanagari';
        font-style: normal;
        font-weight: normal;
        src: url('<?php echo FCPATH; ?>assets/fonts/NotoSansDevanagari-Regular.ttf') format('truetype');
    }

    @font-face {
        font-family: 'NotoSansDevanagari';
        font-style: normal;
        font-weight: bold;
        src: url('<?php echo FCPATH; ?>assets/fonts/NotoSansDevanagari-Bold.ttf') format('truetype');
    }

    body {
        font-family: '<?php echo htmlspecialchars($so_pdf_font); ?>', 'NotoSansDevanagari', 'DejaVu Sans', sans-serif;
        color: #111;
        font-size: 12.5px;
        line-height: 1.6;
        margin: 0;
        padding: 0;
    }

    .hindi {
        font-family: 'NotoSansDevanagari';
    }

    .so-header {
        width: 100%;
        border-collapse: collapse;
    }

    .so-header td {
        border: none;
        vertical-align: top;
        padding: 0;
    }

    .contact {
        text-align: left;
        font-size: 10.5px;
        line-height: 1.55;
    }

    .govt-header {
        text-align: left;
        font-size: 11.5px;
        line-height: 1.5;
        font-weight: bold;
    }

    .date {
        font-size: 12.5px;
        line-height: 1.55;
        text-align: left;
    }

    .content {
        font-size: 12.5px;
        line-height: 1.65;
        text-align: justify;
        margin: 0 0 10px 0;
    }

    .content-center {
        text-align: center;
        font-size: 12.5px;
        line-height: 1.6;
        margin: 26px 0 20px 0;
    }

    .subject {
        font-weight: bold;
        text-align: center;
        font-size: 13.5px;
        line-height: 1.55;
        margin: 14px 0 12px 0;
    }

    .signature {
        text-align: right;
        margin: 0;
        font-weight: 600;
        line-height: 1.55;
        font-size: 12.5px;
    }

    .annexure-signature {
        margin-top: 40px;
    }

    .annexure-title {
        text-align: right;
        font-size: 13px;
        line-height: 1.5;
        margin: 4px 0 10px 0;
    }

    .annexure-table {
        width: 100%;
        border-collapse: collapse;
        margin-top: 8px;
        margin-bottom: 8px;
        font-size: 10.5px;
        line-height: 1.4;
    }

    .annexure-table th,
    .annexure-table td {
        border: 1px solid #222;
        padding: 4px 4px;
        vertical-align: top;
    }

    .annexure-table th {
        text-align: center;
        font-weight: bold;
        background: #f3f3f3;
    }

    .section-logo {
        width: 100%;
        text-align: center;
        margin: 0;
    }

    .section-logo img {
        width: 85px;
        height: 104px;
        max-width: 85px;
        max-height: 104px;
    }

    .section-logo-center {
        width: 100%;
        margin: 0;
    }

    .section-logo-center img {
        width: 100%;
        height: 55px;
        max-height: 55px;
    }

    .terms-title {
        text-align: center;
        font-size: 13.5px;
        font-weight: bold;
        line-height: 1.5;
        margin: 0 0 10px 0;
    }

    .underline {
        display: inline;
        border-bottom: 1px solid #000;
        padding-bottom: 1px;
    }

    ol.content,
    ul.content {
        margin: 0 0 8px 0;
        padding-left: 20px;
    }

    ol.content li,
    ul.content li {
        margin: 0 0 6px 0;
        padding: 0;
        line-height: 1.6;
        text-align: justify;
        font-size: 12.5px;
    }

    .vendor-block {
        font-size: 12.5px;
        line-height: 1.55;
        margin: 0 0 10px 0;
    }

    .fe-heading {
        font-size: 12.5px;
        line-height: 1.55;
        margin: 12px 0 6px 0;
    }

    .page-filler {
        width: 100%;
        border-collapse: collapse;
        border: none;
    }

    .page-filler td {
        border: none;
        padding: 0;
        font-size: 1px;
        line-height: 1px;
    }

    .page1 {
        page-break-after: always;
    }

    .terms-page {
        page-break-after: always;
    }

    /* Page 2 — larger text, still one page with signature */
    .terms-page .content,
    .terms-page ol.content li,
    .terms-page ul.content li {
        font-size: 12.5px;
        line-height: 1.8;
        margin: 0 0 4.5px 0;
    }

    .terms-page ol.content {
        margin-bottom: 6px;
        padding-left: 18px;
    }

    .terms-page .annexure-table {
        margin-top: 6px;
        margin-bottom: 6px;
        font-size: 9.5px;
        line-height: 1.3;
    }

    .terms-page .annexure-table th,
    .terms-page .annexure-table td {
        padding: 3px 3px;
    }

    .terms-page .signature {
        font-size: 12.5px;
        margin: 5px;
    }
</style>

<?php
$vendorName = '';
$BasketName = '';
$USD_Rate = '';
$UKP_Rate = '';
$EUR_Rate = '';
$soDate = $today;
$Discount = '';

if (!empty($report)) {
    $firstRow = $report[0];
    $vendorName = $firstRow->Contract_name ?? '';
    $BasketName = $firstRow->Basket_name ?? '';
    $USD_Rate = $firstRow->USD_Rate ?? '________';
    $UKP_Rate = $firstRow->UKP_Rate ?? '________';
    $EUR_Rate = $firstRow->EUR_Rate ?? '________';
    $soDate = $firstRow->Entry_date ?? $today;
    $Discount = $firstRow->Discount ?? '';
}

/* Prefer PNG for Dompdf (webp support varies). */
$dlrl_logo = is_file(FCPATH . 'uploads/univlogo/DLRL_logo.png')
    ? base_url('uploads/univlogo/DLRL_logo.png')
    : base_url('uploads/univlogo/DLRL_logo.webp');
?>

<!-- ==================== PAGE 1: SUPPLY ORDER (ends with ISO) ==================== -->

<div class="page1">
<table class="so-header">
    <tr>
        <td width="25%" class="contact">
            <span class="hindi">फैक्स</span>/Fax: 040-24440525/24442976/24440093<br>
            <span class="hindi">दूरभाष</span>/Phone: 040-24582446/2423<br>
            email: krc.dlr@gov.in
        </td>
        <td width="40%">
            <div class="section-logo">
                <img src="<?php echo $dlrl_logo; ?>" alt="DLRL Logo" width="85" height="104" style="width:85px;height:104px;">
            </div>
        </td>
        <td width="35%" class="govt-header">
            संख्या/No: <?php echo $BasketName; ?><br>
            भारत सरकार - रक्षा मंत्रालय<br>
            Govt. of India, Ministry of Defence<br>
            रक्षा अनुसंधान एवं विकास संगठन<br>
            Defence Research &amp; Development Organisation<br>
            रक्षा इलेक्ट्रॉनिक्‍स अनुसंधान प्रयोगशाला<br>
            DEFENCE ELECTRONICS RESEARCH LAB<br>
            चंदायणगुटृटा लाईन्स / Chandrayangutta Lines<br>
            हैदराबाद / HYDERABAD-500 005
        </td>
    </tr>
</table>

<table class="so-header" style="margin-top:6px;">
    <tr>
        <td width="25%"></td>
        <td width="40%"></td>
        <td width="35%" class="date">
            <?php
            $document_number = isset($document_number) ? $document_number : '';
            if ($document_number !== '') {
                echo '<b>SO No :</b> ' . htmlspecialchars((string) $document_number) . '<br>';
            }
            ?>
            Date :
            <?php
            echo !empty($soDate)
                ? date('j F Y', strtotime($soDate))
                : '';
            ?>
        </td>
    </tr>
</table>

<p class="content-center">
    <b>All the correspondence must be addressed to Director, DLRL</b><?php if ($signatory_attn !== '') { ?><br>
    <b>Kind Attn: <?php echo htmlspecialchars($signatory_attn); ?></b><?php } ?>
</p>

<p class="content" style="margin-bottom:3px;">To,</p>

<p class="vendor-block">
    M/s. <?php echo htmlspecialchars((string) $vendorName); ?>
</p>

<p class="subject">
    SUB: Supply of Foreign and Indian Print Publications
</p>

<p class="content" style="text-indent: 28px;">
    Kindly supply <span class="underline">publications as per the list enclosed as
    Annexure-I (<?php echo sprintf('%02d', count($report)); ?>-Titles)</span>, with the terms and
    conditions in the overleaf, addressed to The Director,
    Defence Electronics Research Laboratory (DLRL), DRDO,
    Chandrayanagutta Lines, Hyderabad – 500 005,
    Telangana State, India.
</p>

<p class="fe-heading">
    <b class="underline">FE Rates &amp; Discount:</b>
</p>

<ul class="content">
    <li>Conversion Rates 1 USD = Rs. <?php echo htmlspecialchars((string) $USD_Rate); ?>;
        1 UKP = Rs. <?php echo htmlspecialchars((string) $UKP_Rate); ?>;
        1 EUR = Rs. <?php echo htmlspecialchars((string) $EUR_Rate); ?> as on <?php
            echo !empty($soDate) ? date('jS F Y', strtotime($soDate)) : '';
        ?> as per RBI</li>
    <li>Latest edition of the publication(s) must be supplied</li>
    <li>Minimum Discount offered: <?php echo rtrim(rtrim(number_format((float) $Discount, 3, '.', ''), '0'), '.'); ?> %</li>
</ul>

<table class="page-filler" width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td height="140" style="height:140px;line-height:140px;">&nbsp;</td>
    </tr>
</table>

<?php if ($signatory_html !== '') { ?>
<div class="signature">
    <?php echo $signatory_html; ?>
</div>
<?php } ?>

<table class="page-filler" width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td height="35" style="height:35px;line-height:35px;">&nbsp;</td>
    </tr>
</table>

<div class="section-logo-center">
    <img src="<?php echo base_url('uploads/univlogo/dlrl_isio_logo.jpg'); ?>" alt="ISO Certification" width="520" height="55" style="width:100%;height:55px;max-height:55px;">
</div>
</div>

<!-- ==================== PAGE 2: TERMS (ends with signature) ==================== -->

<div class="terms-page">
    <h3 class="terms-title">
        <span style="border-bottom:1px solid #000; padding-bottom:5px;">Terms &amp; Conditions of Supply of Publications</span>
    </h3>

    <ol class="content">
        <li>Receipt of this supply order must be acknowledged by the supplier within a week of its receipt.</li>
        <li>The Due Date for delivery of publications is 30 days from the date of Supply Order.</li>
        <li>The publications must be supplied before the due date to DLRL to maintain efficiency of services.</li>
        <li>In case, the publication(s) is / are not supplied within the due date, the supply order placed to the initial supplier automatically stands cancelled.</li>
        <li>The publication supplied after due date will not be accepted.</li>
        <li>No extension will be given to the supplier for supplying of publication until the publication is imported from foreign nation. In such cases, the correspondence of both publisher and vendor to be submitted for seeking extension.</li>
        <li>If supplier fails to supply three times, the supplier’s registration will be cancelled.</li>
        <li>Proof in support of the prices charged i.e. publisher’s invoice, printed publisher catalogue also to be attached along with the bill(s) for the payment.</li>
        <li>RBI conversion rate prevailing at the time of supply order will only be applicable.</li>
        <li>However, if a book is imported directly from publisher against our supply order, bank conversion rate prevailing at the time of supply may be considered and in such cases the original publisher’s invoice must be produced with the bill.</li>
        <li>In case postal charges are claimed in the bill(s), postal receipt in support must accompany the bill; otherwise postal charges will not be reimbursed.</li>
        <li>Unless otherwise mentioned latest editions of the publications only must be supplied. Evidence of the currency of the editions issued by the publishers must be supplied along with the bill(s).</li>
        <li>The Publications supplied should be in good condition without any defects / damages. Defective/damaged publications will be returned at the supplier’s cost. Payment will be made only after inspection of the publications by the Wing Head, Knowledge Resource Centre, DLRL.</li>
        <li>100% payment through PCDA, Hyderabad after acceptance of the publications.</li>
        <li>No photocopy of publications, printout of the softcopy or pirated copy of the publications will be accepted. Any vendor involved in such practices will be blacklisted.</li>
        <li>For e-books, the publisher/Authorized distributor should provide Perpetual Access Rights to our Institutional IP range mentioned as below to the e-publications purchased/subscribed by DLRL.</li>
    </ol>

    <table class="annexure-table">
        <tr>
            <th>S.No</th>
            <th>Site Name</th>
            <th>Location</th>
            <th>State</th>
            <th>State ID</th>
            <th>LAN IP Pool (/22)</th>
            <th>Public IP Pool Delhi</th>
            <th>Public IP Pool Hyderabad</th>
        </tr>
        <tr>
            <td style="text-align:center;">1</td>
            <td>DLRL</td>
            <td>Hyderabad</td>
            <td>Telangana</td>
            <td style="text-align:center;">169</td>
            <td>10.39.0.0</td>
            <td>218.185.252.169</td>
            <td>218.185.254.169</td>
        </tr>
        <tr>
            <td style="text-align:center;">2</td>
            <td>ELSEC</td>
            <td>Hyderabad</td>
            <td>Telangana</td>
            <td style="text-align:center;">173</td>
            <td>10.42.0.0</td>
            <td>218.185.252.173</td>
            <td>218.185.254.173</td>
        </tr>
    </table>

    <ol class="content" start="17">
        <li>Pre-receipt bill(s) should to be submitted in triplicate (3 copies). The original bill should be duly stamped with a revenue stamp in case the amount of the bill exceeds Rs.5000/-.</li>
        <li>Enclose a copy of the respective supply order(s) with the bill and clearly indicate the supplied document(s).</li>
        <li>Bill(s) is / are to be addressed to: The Director, DLRL, Chandrayanagutta Lines, Hyderabad – 500 005.</li>
        <li>The Director, DLRL reserves all rights to cancel a supply order or part of it at any moment of time without assigning any reason.</li>
    </ol>

    <table class="page-filler" width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td height="30" style="height:30px;line-height:30px;">&nbsp;</td>
        </tr>
    </table>

    <?php if ($signatory_html !== '') { ?>
    <div class="signature">
        <?php echo $signatory_html; ?>
    </div>
    <?php } ?>
</div>

<!-- ==================== PAGE 3+: ANNEXURE ==================== -->

<div class="annexure-title">
    <b>Annexure-I</b><br>
    <b>S.O.No:</b> <?php echo htmlspecialchars((string) $BasketName); ?>
</div>
<p class="vendor-block"><b>M/s. <?php echo htmlspecialchars((string) $vendorName); ?></b></p>

<table class="annexure-table">
    <thead>
        <tr>
            <th width="7%">S.No</th>
            <th width="18%">Author</th>
            <th width="35%">Title</th>
            <th width="18%">Publisher</th>
            <th width="10%">Year</th>
            <th width="12%">ISBN</th>
        </tr>
    </thead>
    <tbody>
        <?php
        $sno = 1;
        foreach ($report as $row) {
        ?>
            <tr>
                <td style="text-align:center;"><?php echo $sno++; ?></td>
                <td><?php echo $row->Author ?? ''; ?></td>
                <td><?php echo $row->Title ?? ''; ?></td>
                <td><?php echo $row->Publisher ?? ''; ?></td>
                <td style="text-align:center;"><?php echo $row->Publication_year ?? ''; ?></td>
                <td><?php echo $row->ISBN ?? ''; ?></td>
            </tr>
        <?php } ?>
    </tbody>
</table>

<?php if ($signatory_html !== '') { ?>
<div class="signature annexure-signature">
    <?php echo $signatory_html; ?>
</div>
<?php } ?>
