<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>

<style>
    page {
        width: 21.7cm;
        height: 27.95cm;
        padding: 0px !important;
        margin: 0px !important;
        border: 0 !important;
        position: relative;
    }
    .modal-body{
        padding: 0px !important;
        margin: 0px !important;
    }
    .no-modal-header .close {
        margin-top: 1px;
    }
    .nopadding{
        padding: 0px;
        margin: 0px;
    }
    .pb_0{
        padding-bottom: 0px !important;
    }
    .inline-flex{
        display: inline-flex;
    }
    .text-center{
        text-align: center !important;
    }
    .top_section {
        height: 5.3cm;
        position: relative;
        width: 20.5cm;
        margin: 0 auto;
    }
    .top_section h2 {
        font-size: 23px;
        color: #fa0c11;
    }
    .top_section p {
        color: #013a0e;
        font-size: 15px;
        font-weight: 600;
    }
    .top_section p span {
        color: #fa0c11;
        font-size: 12px;
    }
    .top_center p {
        font-size: 13px;
        font-weight: 600;
    }
    .top_center .logo {
        position: relative;
        right: 35px;
    }
    .top_heading_section .text-right, .top_heading_section .text-left {
        width: 31%;
        padding: 3px !important;
    }
    .top_heading_section span {
        background: #fa0c11;
        color: #fff;
        padding: 6px;
        font-size: 17px;
        font-weight: bold;
        width: 38%;
    }
    .top_heading_section {
        position: absolute;
        top: 17%;
        text-align: center;
        width: 100%;
    }
    .customer_detaile_section {
        width: 20.5cm;
        margin: 0 auto;
        border: 2px solid #fa0c11;
        border-radius: 10px;
        height: 2.1cm !important;
    }
    .pt_cust_row {
        padding-top: 0.1cm !important;
    }
    .product_table_section {
        height: 15.2cm;
        width: 20.5cm !important;
        margin: 0 auto;
        border: 1px solid #fa0c11;
        margin-top: 3px;
    }
    .greenf{
        color: #013a0e;
    }
    .redf{
        color: #fa0c11;
    }
    .product_table_section .table > thead:first-child > tr:first-child > th {
        background-color: #ffffff;
        color: white;
        border-color: #fa0c11;
        border-top: 1px solid #fa0c11;
        text-align: left;
        font-family: 'times new roman';
        font-weight: lighter;
    }
    .sl_col_th {
        width: 1cm !important;
    }
    .sku_col_th {
        width: 1.2cm !important;
    }
    .desc_col_th {
        width: 8cm !important;
    }
    .qty_col_th {
        width: 1.5cm !important;
    }
    .unit_col_th {
        width: 1cm !important;
    }
    .unit_p_col_th {
        width: 1.5cm !important;
    }
    .total_p_col_th {
        width: 1.7cm !important;
    }
    .vat_perc_col_th {
        width: 0.8cm !important;
    }
    .vat_sar_col_th {
        width: 1.4cm !important;
    }
    .total_amnt_col_th{
        width: 2.4cm !important;
    }
    .product_table_section .table>thead>tr>th, .product_table_section .table>tbody>tr>th, .product_table_section .table>thead>tr>td, .product_table_section .table>tbody>tr>td {
        padding: 2px;
        line-height: 1;
        vertical-align: top;
        border-top: 1px solid #ccc;
    }
    .invoice_table_bottom{
        width: 20.5cm !important;
        height: 3.6cm !important;
        margin: 0 auto;
        position: relative;
    }
    .invoice_table_bottom table tbody {
        height: 3.6cm !important;
        font-size: 12px;
    }
    .invoice_table_bottom table tbody tr th {
        padding: 0px !important;
    }
    .signature_td{
        width: 14.3cm !important;
    }
    .tfoot_scnd_td{
        width: 2.5cm !important;
    }
    .tfoot_third_td{
        width: 3.7cm !important;
    }
    .product_table_section .table-bordered>thead>tr>th, .product_table_section .table-bordered>tbody>tr>th, .product_table_section .table-bordered>tfoot>tr>th, .product_table_section .table-bordered>thead>tr>td, .product_table_section .table-bordered>tbody>tr>td, .product_table_section .table-bordered>tfoot>tr>td {
        border: 1px solid #fa0c11;
    }
    .invoice_table_bottom .table-bordered>thead>tr>th, .invoice_table_bottom .table-bordered>tbody>tr>th, .invoice_table_bottom .table-bordered>tfoot>tr>th, .invoice_table_bottom .table-bordered>thead>tr>td, .invoice_table_bottom .table-bordered>tbody>tr>td, .invoice_table_bottom .table-bordered>tfoot>tr>td {
        border: 1px solid #fa0c11;
    }
    .right_2{
        position: absolute;
        right: 1.5cm;
    }
    .signature_td .col-md-4{
        position: relative;
        top:50px;
    }
    .order_barcodes {
        position: absolute;
        bottom: 6px;
        left: 72%;
    }
    .order_barcodes img{
        width: 24%;
    }
    .page_number {
        position: absolute;
        left: 10px;
        top: 5px;
    }
    @media print{
        *{ 
            overflow: visible !important; 
        } 
        page{ 
            page-break-after:always; 
        }
        page{
            width: 21.7cm;
            height: 27.95cm;
            padding: 0px !important;
            position: relative;
        }
        @page{
            margin:0 auto !important;
        }
        .no_print{
            display: none !important;
        }
        .nopadding{
            padding: 0px;
            margin: 0px;
        }
        .inline-flex{
            display: inline-flex;
        }
        .text-center{
            text-align: center !important;
        }
        .button_section{
            visibility: hidden !important;
        }
        .text-right{
            text-align: right !important;
        }
        .text-left{
            text-align: left !important;
        }
        .top_heading_section {
            top: 16%;
        }
        .top_heading_section .col-md-4{
            float: left;
        }
        .top_heading_section .text-right, .top_heading_section .text-left {
            width: 5cm !important;
            padding: 3px !important;
        }
        .top_heading_section .text-left {
            margin-left: 8.5cm !important;
        }
        .customer_detaile_section {
            width: 20.5cm;
            margin: 0 auto;
            border: 2px solid #fa0c11;
            border-radius: 10px;
            height: 2.1cm !important;
            padding-right: 70px !important;
            padding-top: 6cm !important;
            position: absolute !important;
            right: 20px;
        }
        .customer_detaile_section .col-md-12{
            width: 100% !important;
        }
        .customer_detaile_section .col-md-7{
            width: 58.33333333% !important;
        }
        .customer_detaile_section .col-md-5{
            width: 41.66666667% !important;
        }
        .customer_detaile_section .col-md-7, .customer_detaile_section .col-md-5{
            float: left;
        }
        .left_2_5{
            padding-left: 2.5cm !important;
        }
        .left_4{
            padding-left: 4cm !important;
        }
        .left_3_5{
            padding-left:3.5cm !important;
        }
        .left_1_5{
            padding-left:1.5cm !important;
        }
        .left_0_5{
            padding-left: 0.5cm !important;
        }
        .top_0_2{
            position: relative;
            top: 0.2cm;
        }
        .top_0_3{
            position: relative;
            top: 0.3cm;
        }
        .product_table_section {
            height: 15.2cm;
            width: 20.5cm !important;
            margin: 0 auto;
            margin-top: 7cm !important;
        }
        .sl_col_td {
            width: 1cm !important;
            position: relative !important;
            left: -0.4cm !important;
            top: 3cm !important;
            padding-bottom:.5cm !important;
        }
        .sku_col_td {
            width: 1.2cm !important;
            position: relative !important;
            left: -0.6cm !important;
            top: 3cm !important;
            padding-bottom:.5cm !important;
        }
        .desc_col_td {
            width: 8cm !important;
            position: relative !important;
            left:-0.4cm;
            top: 3cm;
            padding-bottom:.5cm !important;
        }
        .qty_col_td {
            width: 1cm !important;
            position: relative !important;
            left: 0.6cm !important;
            top: 3cm;
            padding-bottom:.5cm !important;
        }
        .unit_col_td {
            width: 1.5cm !important;
            position: relative !important;
            left: 1.2cm !important;
            top: 3cm;
            padding-bottom:.5cm !important;
        }
        .unit_p_col_td {
            width: 1.5cm !important;
            position: relative !important;
            left: 1cm !important;
            top: 3cm;
            padding-bottom:.5cm !important;
        }
        .total_p_col_td {
            width: 1.7cm !important;
            position: relative !important;
            left: 1.1cm !important;
            top: 3cm;
            padding-bottom:.5cm !important;
        }
        .vat_perc_col_td {
            width: 0.8cm !important;
            position: relative !important;
            left: 1.4cm !important;
            top: 3cm;
            padding-bottom:.5cm !important;
        }
        .vat_sar_col_td {
            width: 1.4cm !important;
            position: relative !important;
            left: 1.5cm !important;
            top: 3cm;
            padding-bottom:.5cm !important;
        }
        .total_amnt_col_td {
            width: 2.4cm !important;
            position: relative !important;
            left: 1.8cm !important;
            top: 3cm;
            padding-bottom:.5cm !important;
        }
        .return_items{
            position: relative !important;
            top: 3cm;
            padding-bottom:.5cm !important;
            left:1.8cm;
        }
        .invoice_table_bottom{
            width: 20.5cm !important;
            height: 3.6cm !important;
            margin: 0 auto;
            padding-top: .2cm !important;
            position:relative;
        }
        .invoice_table_bottom table tbody {
            height: 3.6cm !important;
            font-size: 12px;
        }
        .tfoot_scnd_td{
            margin-left: 16.5cm !important;
            position: relative;
            left:2cm;
            top:4cm;
            margin-bottom: 2cm !important;
        }
        .product_table_section .table-bordered>thead>tr>th, .product_table_section .table-bordered>tbody>tr>th, .product_table_section .table-bordered>tfoot>tr>th, .product_table_section .table-bordered>thead>tr>td, .product_table_section .table-bordered>tbody>tr>td, .product_table_section .table-bordered>tfoot>tr>td {
            border: 0px !important;
        }
        .invoice_table_bottom .table-bordered>thead>tr>th, .invoice_table_bottom .table-bordered>tbody>tr>th, .invoice_table_bottom .table-bordered>tfoot>tr>th, .invoice_table_bottom .table-bordered>thead>tr>td, .invoice_table_bottom .table-bordered>tbody>tr>td, .invoice_table_bottom .table-bordered>tfoot>tr>td {
            border: 0px !important;
        }
        .invoice_table_bottom table tbody tr th {
            padding: 8px !important;
            padding-right: 2cm !important;
        }
        .order_barcodes {
            position: absolute;
            left: 72%;
            top:.5cm;
        }
        .order_barcodes img{
            width: 26%;
        }
        .page_number {
            position: absolute;
            left: 10px;
            top: 4.5cm;
        }
    }
</style>
<?php $a = count($rows);
           $ceil = $a/10;
           $value = ceil($ceil);
           //print_r( $value);die();
           $j = 0; $k=0;$r = 1; $ten=9;
           
           for($h=1;$h<= $value;$h++){
          $ten = 10 * $h;
           
           ?>

<div class="modal-dialog modal-lg no-modal-header">
    <page>
        <div class="container nopadding">
            <div class="row button_section no_print">
                <div class="col-md-12 pb_0">
                    <div class="col-md-12 pb_0">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            X
                        </button>
                        <button type="button" class="btn btn-xs btn-default no-print pull-right" style="margin-right:15px;" onclick="myFunction();">
                            <i class="fa fa-print"></i> <?= lang('print'); ?>
                        </button>
                    </div>
                </div>
            </div>
            <div class="row top_section no_print">
                <div class="col-md-4 text-left">
                    <h2><?= $biller->company != '-' ? $biller->company : $biller->name; ?></h2>
                    <p> <?php
                    echo $biller->address . "<br>"  . $biller->postal_code . "<br>" ;
                    echo lang("Tel") . "  #  " . $biller->phone."<br>";
                    echo lang("Fax") . "  #  "."<br>"; ?>
                    <!-- <p>C.R. 1010141713<br>
                    P.O.Box: 25024 - Riyadh: 11466<br>
                    Tel # 00966 - 11 - 2749090<br>
                    Fax # 00966 - 11 - 2746060<br> -->
                    <span>E-mail : <?php echo $biller->email?></span></p>
                </div>
                    
                <div class="col-md-4 text-center top_center">
                    <img class="logo" src="<?= base_url() . 'assets/uploads/logos/' . $Settings->logo; ?>" alt="logo">
                    <p>ضريبة القيمة المضافة لا : <?php echo $biller->vat_no . "<br>";
                     echo lang("VAT No.") . ":" .$biller->vat_no;?>
                    </p>
                </div>
                    
                <div class="col-md-4 text-right arabic_text" dir="rtl">
        
                    <h2> <?php if ($biller->cf1 != "-" && $biller->cf1 != "") {
                        echo "<b>" . $biller->cf1  . "<br>";
                    } ?></h2>
                    <p>  <?php if ($biller->cf2 != "-" && $biller->cf2 != "") {
                        echo "" . $biller->cf2 . "<br>";
                    } ?>   
                    <?php if ($biller->cf3 != "-" && $biller->cf3 != "") {
                        echo "" . $biller->cf3 .  "<br>";
                    } ?> 
                     <?php if ($biller->cf4 != "-" && $biller->cf4 != "") {
                        echo "" . $biller->cf4 .  "<br>";
                    } ?>   
                     <?php if ($biller->cf5 != "-" && $biller->cf5 != "") {
                        echo "" . $biller->cf5 .  "<br>";
                    } ?> 
                    <span> <?php if ($biller->cf6 != "-" && $biller->cf6 != "") {
                        echo "" . $biller->cf6 . "</b>" . "<br>";
                    } ?> </span></p>
                </div>
            </div>
            
            <div class="row top_heading_section inv">
                 <?php if (empty($inv->sale_id) ){ ?>
                <div class="col-md-12 text-center">
                    <small class="col-md-4"></small>
                   <span class="col-md-4 nopadding no_print">VAT INVOICE  فاتورة ضريبة القيمة المضافة</span> 
                    <small class="col-md-4"></small>
                </div>
                <?php } else {  ?>

                     <div class="col-md-12 text-center">
                         <small class="col-md-4 nopadding text-right"><b>SALES RETURN/ عودة المبيعات </b></small>
                    <span class="col-md-4 nopadding no_print">VAT INVOICE  فاتورة ضريبة القيمة المضافة</span>
                     <small class="col-md-4 nopadding text-left"><b> Org.Inv.#/رقم فاتورة المبيعات المرتجعة:  :<?=$inv->orginal_inv ?></b></small>
                </div>
                <?php } ?>
            </div>


           
            
            <div class="row customer_detaile_section">
                <div class="col-md-12">
                    <div class="">
                        <div class="col-md-12 nopadding pt_cust_row">
                            <span class="pull-left no_print">Customer's Name: </span>&nbsp;&nbsp;
                            <span class="left_2_5"><?= $customer->company ? $customer->company : $customer->name; ?></span>
                            <span class="right_2"><?= $customer->cf2?></span>&nbsp;&nbsp;
                            <span class="pull-right no_print">: اسم العميل </span>
                        </div>
                        <div class="col-md-7 nopadding pt_cust_row">
                            <span class="top_0_2"><?= $customer->address . $customer->city . " " . $customer->postal_code . " " . $customer->state . $customer->country; ?></span>
                        </div>
                      
                         <!-- <?php if (!empty($inv->orginal_inv)) {
                            echo lang("Orginal Invoice Number/رقم فاتورة المبيعات المرتجعة").': '.$inv->orginal_inv;
                            if ($inv->return_id) {
                                echo ' <a data-target="#myModal2" data-toggle="modal" href="'.admin_url('purchases/modal_view/'.$inv->return_id).'"><i class="fa fa-external-link no-print"></i></a><br>';
                            } else {
                                echo '<br>';
                            }
                        } ?> -->
                        <div class="col-md-5 nopadding pt_cust_row">
                            
                            <span class="pull-left no_print">|Inv.No.:</span> 
                            <span class="left_4 top_0_2"><?= $inv->reference_no; ?></span>
                            <span class="pull-right no_print">:رقم الفاتورة</span>
                        </div>
                        <div class="col-md-7 nopadding pt_cust_row">    
                            <span class="pull-left no_print">VAT:</span>
                            <span class="left_0_5 top_0_3"><?= $customer->vat_no; ?></span>
                            <span class="pull-right no_print">:ضريبة القيمة المضافة  </span> 
                        </div>  
                        <div class="col-md-5 nopadding pt_cust_row">
                            &nbsp;&nbsp;<span class="divider no_print"></span>
                            <span class="pull-left no_print">| Date:</span>   
                            <span class="left_3_5 top_0_3"><?= $this->sma->hrld($inv->date); ?></span>
                            <span class="pull-right no_print">:تاريخ</span>
                        </div>


                    </div>
                </div>
            </div>

            <div class="row product_table_section">
                <div class="col-md-12 nopadding">
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover table-striped print-table order-table">
        
                            <thead class="no_print">
                                <tr>
                                    <th class="text-center sl_col_th"><span class="greenf"> رقم سري </span> <br> <span class="redf"><?= lang("S.NO"); ?></span></th>
                                    <th class="text-center sku_col_th"><span class="greenf"></span> <br> <span class="redf">SKU</span></th>
                                    <th class="text-center desc_col_th"><span class="redf">Description</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="greenf"> وصف</span></th>
                                    <th class="text-center qty_col_th"><span class="greenf">جودة </span> <br> <span class="redf"> Qty</span></th>
                                    <th class="text-center unit_col_th"><span class="greenf">وحدة </span> <br> <span class="redf">Unit</span></th>
                                    <th class="text-center unit_p_col_th"><span class="greenf">سعر الوحدة </span> <br> <span class="redf"> U.Price</span></th>
                                    <th class="text-center total_p_col_th"><span class="greenf">ضريبة القيمة المضافة<br>السعر الإجمالي باستثناء <br> <span class="redf"> T.Price Excl. Vat </span></span></th>
                                    <th class="text-center vat_perc_col_th"><span class="greenf">ضريبة </span> <br> <span class="redf">Vat %</span></th>
                                    <th class="text-center vat_sar_col_th"><span class="greenf"></span><br> <span class="redf">Vat in SAR</span></th>
                                    <th class="text-center total_amnt_col_th"><span class="greenf">المبلغ الإجمالي </span><br> <span class="redf">Total Amount</span></th>
                                </tr>
                            </thead>
        
                            <tbody>
                       <?php 
                       $r = 1;
                       $sub=$qty=0;
                       
                       foreach (array_slice($rows, $j,$ten) as $row):
                        ?>
                                <tr class="table_row">
                                    <td class="sl_col_td"><?= $j; ?></td>
                                    <td class="sku_col_td"><?= $row->product_code?></td>
                                    <td class="desc_col_td">
                                        <span class="pull-left"><?= $row->product_name?></span>
                                        <span class="pull-right">موز أصفر</span>
                                    </td>
                                    <td class="qty_col_td"><?= $this->sma->formatQuantity($row->quantity)?></td>
                                    <td class="unit_col_td"><?= $row->product_unit_code?></td>
                                    <td class="unit_p_col_td"><?= $this->sma->formatMoney($row->net_unit_price); ?></td>
                                    <?php
                                    $qty = $row->unit_quantity * $row->net_unit_price;
                                    $sub+=$qty;
                                    ?>
                                    <td class="total_p_col_td"><?= $this->sma->formatMoney($qty); ?></td>
                                    <td class="vat_perc_col_td"><?= $row->tax ?></td>
                                    <?php
                                    // $qty = $row->quantity * $this->sma->formatMoney($row->net_unit_price);
                                    $tax = $row->tax;
                                    $tot_vat = $qty * $tax/100;
                                    $tot_amt = $qty + $tot_vat;
                                    //$sub+=$tot_amt;
                                    //$final_tot_amt = $tot_amt + 
                                    ?>
                                    <td class="vat_sar_col_td"><?= $this->sma->formatMoney($tot_vat) ?></td>
                                    
                                    <td class="total_amnt_col_td"><?= $this->sma->formatMoney($tot_amt) ?></td>

                                </tr>
                           <?php
                          $r++;
                           $j++;
                        if(($j%10) == 0 )break;
                    
                        endforeach; 
                            
                          if ($return_rows) {
                            echo '<tr class=""><td colspan="100%" class="return_items"><strong>'.lang('returned_items').'</strong></td></tr>';
                       foreach (array_slice($return_rows, $k,$ten) as $row):
                            //foreach ($return_rows as $row):
                                
                                  $qty1 = $row->quantity * $row->net_unit_price;
                                 
                            ?>
                           <?php $r = 1; ?>
                          <tr class="table_row1">
                                    <td class="sl_col_td"><?= $k; ?></td>
                                    <td class="sku_col_td"><?= $row->product_code?></td>
                                    <td class="desc_col_td">
                                        <span class="pull-left"><?= $row->product_name?></span>
                                        <span class="pull-right">موز أصفر</span>
                                    </td>
                                    <td class="qty_col_td"><?= $this->sma->formatQuantity($row->quantity)?></td>
                                    <td class="unit_col_td"><?= $row->product_unit_code?></td>
                                    <td class="unit_p_col_td"><?= $this->sma->formatMoney($row->net_unit_price); ?></td>
                                    <?php
                                    $qty = $row->unit_quantity * $row->net_unit_price;
                                    $sub+=$qty;
                                    ?>
                                    <td class="total_p_col_td"><?= $this->sma->formatMoney($qty); ?></td>
                                    <td class="vat_perc_col_td"><?= $row->tax ?></td>
                                    <?php
                                    // $qty = $row->quantity * $this->sma->formatMoney($row->net_unit_price);
                                    $tax = $row->tax;
                                    $tot_vat = $qty * $tax/100;
                                    $tot_amt = $qty + $tot_vat;
                                    //$sub+=$tot_amt;
                                    //$final_tot_amt = $tot_amt + 
                                    ?>
                                    <td class="vat_sar_col_td"><?= $this->sma->formatMoney($tot_vat) ?></td>
                                    
                                    <td class="total_amnt_col_td"><?= $this->sma->formatMoney($tot_amt) ?></td>

                                </tr>


                            
                           <?php
                                $r++;
                                $k++;
                        if(($k%7) == 0 )break;
                        else
                            if(($k%4) == 0 )break;
                            endforeach;
                        }
                        ?> 
                            </tbody>
                            
                        </table>
                    </div>
                </div>
            </div>
            
           
            <div class="row invoice_table_bottom">
                <div class="col-md-12 nopadding">
                    <div class="table-responsive">
                        <table class="table table-bordered vat_invoice_table_bottom">
                            <tbody>
                                <tr>
                                    <th class="signature_td no_print" colspan="6" rowspan="4">
                                        <span class="col-md-4 text-center">
                                            <span class="greenf no_print">تلقاها</span> <br> <span class="redf no_print">Recieved By</span>
                                        </span>
                                        <span class="col-md-4 text-center">
                                            <span class="greenf no_print">تمت الموافقة عليه من قبل </span><br> <span class="redf no_print">Approved By</span>
                                        </span>
                                        <span class="col-md-4 text-center">
                                            <span class="greenf no_print">أعدت بواسطة </span><br> <span class="redf no_print">Prepared By</span>
                                        </span>
                                        <span class="qr_code">
                                            
                                        </span>
                                    </th>
                                    <th class="tfoot_scnd_td no_print" colspan="2"><span class="greenf no_print">المبلغ الإجمالي </span><br> <span class="redf no_print">Total Amount</span></th>
                                    <th class="tfoot_scnd_td" colspan="2"><?= $inv->total; ?></th>
                                </tr>
                                <tr>
                                    <th class="tfoot_scnd_td no_print" colspan="2"><span class="greenf no_print">قيمة الضريبة </span><br> <span class="redf no_print">Vat Amount</span></th>
                                    <th class="tfoot_scnd_td" colspan="2"><?= $inv->product_tax; ?></th>
                                </tr>
                                <tr>
                                    <th class="tfoot_scnd_td no_print" colspan="2"><span class="greenf no_print">مقدار الخصم </span><br> <span class="redf no_print">Disc. Amount</span></th>
                                    <th class="tfoot_scnd_td" colspan="2"><?= $inv->product_discount; ?></th>
                                </tr>
                                <?php
                                $grand_tot = $inv->total + $inv->product_tax;

                                ?>
                                <tr>
                                    <th class="tfoot_scnd_td no_print" colspan="2"><span class="greenf no_print">المجموع الإجمالي </span><br> <span class="redf no_print">Grand Total</span></th>
                                    <th class="tfoot_scnd_td" colspan="2"><?= $grand_tot; ?></th>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="page_number">
                    <span>Page #:</span>
                </div>
                <!--qrcode-->
                <div class="col-xs-7">
                  <div class="col-xs-12 order_barcodes">
                     <?php 
                     $seller_name = $biller->company;
                    // $seller_name = bin2hex($seller_name);
                     $name = strlen($biller->company);
                     $tag_name ='01';
                     $length_name =$name;
                     $first_tag = $tag_name.''.$name;
                     $first_tag_hex = $this->sma->dec2hex($length_name);
                     if(strlen($first_tag_hex) == '1'){
                         $first_tag_hex ='0'.''.$first_tag_hex;
                     }
                     else{
                         $first_tag_hex = $first_tag_hex;
                     }
                     
                     //$first_tag_hex_to_string = hex2bin($first_tag_hex);
                     $seller_name = $this->sma->hex2str($tag_name).''.$this->sma->hex2str($first_tag_hex).''.$seller_name;
                     //$this->sma->hex2str($content)
                     $seller_vat = $biller->vat_no;
                    // $seller_vat = bin2hex($seller_vat);
                     $vat = strlen($seller_vat);
                     $tag_vat ='02';
                     $length_vat =$vat;
                     $second_tag = $tag_vat.''.$vat;
                     $second_tag_hex =  $this->sma->dec2hex($length_vat);
                     if(strlen($second_tag_hex) == '1'){
                         $second_tag_hex ='0'.''.$second_tag_hex;
                     }
                     else{
                         $second_tag_hex = $second_tag_hex;
                     }
                    // $second_tag_hex_to_string = hex2bin($second_tag_hex);
                    
                     $seller_vat = $this->sma->hex2str($tag_vat).''.$this->sma->hex2str($second_tag_hex).''.$seller_vat;
                   
                     $seller_date = $inv->date;
                     //$seller_date = bin2hex($seller_date);
                     $date = strlen($inv->date);
                     $tag_date ='03';
                     $length_date =$date;
                     $third_tag = $tag_date.''.$date;
                     $third_tag_hex = $this->sma->dec2hex($length_date);
                     if(strlen($third_tag_hex) == '1'){
                         $third_tag_hex ='0'.''.$third_tag_hex;
                     }
                     else{
                         $third_tag_hex = $third_tag_hex;
                     }
                    // $third_tag_hex_to_string = hex2bin($third_tag_hex);
                     $seller_date = $this->sma->hex2str($tag_date).''.$this->sma->hex2str($third_tag_hex).''.$seller_date;
                       
                     $seller_invoice_total = $this->sma->formatQuantity($inv->grand_total);
                    // $seller_invoice_total =bin2hex($seller_invoice_total);
                     $grand = strlen($this->sma->formatQuantity($inv->grand_total));
                     $tag_grand ='04';
                     $length_tot =$grand;
                     $fourth_tag = $tag_grand.''.$grand;
                     $fourth_tag_hex = $this->sma->dec2hex($length_tot);
                     if(strlen($fourth_tag_hex) == '1'){
                         $fourth_tag_hex ='0'.''.$fourth_tag_hex;
                     }
                     else{
                         $fourth_tag_hex = $fourth_tag_hex;
                     }
                     //$fourth_tag_hex_to_string = hex2bin($fourth_tag_hex);
                     $seller_invoice_total =$this->sma->hex2str($tag_grand).''.$this->sma->hex2str($fourth_tag_hex).''.$seller_invoice_total;
                    
                     $vat_values ='15';
                     $seller_vat_value = $this->sma->formatQuantity($vat_values);
                     // $seller_vat_value =  bin2hex($seller_vat_value); 
                     $vat_value = strlen($this->sma->formatQuantity($vat_values));
                     $tag_vat_value ='05';
                     $length_vat =$vat_value;
                     $fifth_tag = $tag_vat_value.''.$vat_value; 
                     $fifth_tag_hex = $this->sma->dec2hex($length_vat);
                     if(strlen($fifth_tag_hex) == '1'){
                         $fifth_tag_hex ='0'.''.$fifth_tag_hex;
                     }
                     else{
                         $fifth_tag_hex = $fifth_tag_hex;
                     }
                    // $fifth_tag_hex_to_string = hex2bin($fifth_tag_hex);
                     $seller_vat_value = $this->sma->hex2str($tag_vat_value).''.$this->sma->hex2str($fifth_tag_hex).''.$seller_vat_value;
                    //print_r($seller_vat_value);
                     
                     $content = $seller_name.''.$seller_vat.''.$seller_date.''.$seller_invoice_total.''.$seller_vat_value;
                     
                      ?>
              <br>
          <?php  //$bin =$this->sma->hex2str($content);
$b64 = base64_encode($content); //print_r($content);

?>
   <?= $this->sma->new_qrcode('link',$b64, 256); ?>
                    
                         </div>
                    <div class="clearfix"></div>
                </div>
            <!--end-->
            </div>
            
        </div>
    </page>
      <?php }?>
</div>

<script type="text/javascript">
  function myFunction() {
    window.print();
}
    $(document).ready( function() {
        $('.tip').tooltip();
    });
</script>
