<?php
//$this->load->library('ForeignExchange');
//$fx = new ForeignExchange('BDT', 'USD');
if ($invoice_info) {
    $i = 0;
    foreach ($invoice_info as $value) {
        $i++;
        ?>
        <div class="col-sm-12 <?php echo ($i % 2) ? 'gray' : 'white'; ?> text-center" >
            <div class="col-sm-3 form-group"><?php echo '#tt-' . $random_id[$value->invoice_id]; ?></div>
            <div class="col-sm-2 form-group"><?php echo date("F j, Y", strtotime($value->invoice_created_date)); ?></div>
            <div class="col-sm-2 form-group"><?php
                if (isset($invoice_payment_info[$value->invoice_id])) {
                    echo date('F j, Y', strtotime($invoice_payment_info[$value->invoice_id]->invoice_paid_date));
                } else {
                    echo '-';
                }
                ?></div>
            <div class="col-sm-2 form-group"><?php
                if (isset($invoice_payment_info[$value->invoice_id])) {
                    if ($invoice_payment_info[$value->invoice_id]->currency_type == 1) {
                        
                        //echo 'BDT ' . $invoice_payment_info[$value->invoice_id]->paid_amount . ' / USD ' . $this->tt_currency->set($invoice_payment_info[$value->invoice_id]->paid_amount, 'BDT', 'USD')->convert_currency()->get();
                        echo 'BDT ' . $invoice_payment_info[$value->invoice_id]->paid_amount;
                    } else if ($invoice_payment_info[$value->invoice_id]->currency_type == 2) {
                        
                        //echo 'BDT ' . $this->tt_currency->set($invoice_payment_info[$value->invoice_id]->paid_amount, 'USD', 'BDT')->convert_currency()->get() . ' / USD ' . $invoice_payment_info[$value->invoice_id]->paid_amount;
                        echo ' USD ' . $invoice_payment_info[$value->invoice_id]->paid_amount;
                    }
                }                                         
                else{
                    ?>
                <strong style="color:red">
                <?php 
                    if ($value->payment_currency == 1) {
                        
                        //echo 'BDT ' . $due_payment[$value->invoice_id] . ' / USD ' . $this->tt_currency->set($due_payment[$value->invoice_id], 'BDT', 'USD')->convert_currency()->get();
                        echo 'BDT ' . $due_payment[$value->invoice_id];
                    } else if ($value->payment_currency == 2) {
                        
                        //echo 'BDT ' . $this->tt_currency->set($due_payment[$value->invoice_id], 'USD', 'BDT')->convert_currency()->get() . ' / USD ' . $due_payment[$value->invoice_id];
                        echo ' USD ' . $due_payment[$value->invoice_id];
                    }
                ?>
                </strong>
                <?php }  ?>
            </div>
            <div class="col-sm-2 form-group">
                <strong>
                    <?php
                    switch ($value->payment_status) {
                        case 1:
                            echo 'Paid';
                            break;
                        case 2:
                            echo 'Partial Paid';
                            break;
                        case 3:
                            echo 'Unpaid';
                            break;
                        case 4:
                            echo 'Drop';
                            break;
                        case 5:
                            echo 'Cancel';
                            break;
                        case 6:
                            echo 'Pending';
                            break;
                        case 7:
                            echo 'Refund Request';
                            break;
                        case 8:
                            echo 'Refunded';
                            break;
                        default :
                            echo 'None';
                            break;
                    }
                    ?>
                </strong>
            </div>

            <div class="col-sm-1 padding-zero text-center">
                <a href="<?php echo base_url('user/view-invoice/' . $random_id[$value->invoice_id]); ?>" target="_blank"><i class="fa fa-dollar" title="Details"></i></a>&nbsp;
                <?php
                //if (in_array($value->payment_status, [1, 2]) && $this->session->person_id == $value->person_id) {
                    ?>
<!--                    <a href="javascript:void(0)" id="refundRequestInvoice<?php //echo $random_id[$value->invoice_id]; ?>"><i class="fa fa-arrow-right" title="Refund Request" aria-hidden="true"></i></a>-->
                <?php //} ?>
            </div>
            <div class="modal fade" style="" id="viewRefundRequestInvoiceModal" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
                <?php
                $message3 = '<span style="text-align:center">Are you sure you want to refund this Invoice?</span>';
                $this->cf->view_modal('refundImvoice', $message3);
                ?>
            </div>
            <input type="hidden" id="hiddenPaymentStatus<?php echo $random_id[$value->invoice_id]; ?>" value="<?php echo $value->payment_status ?>">
        </div>
        <?php
    }
    echo $paginzation_link;
}