<div class="wrapper">
    <div class="container">
         <!-- Page-Title -->
        <div class="row">
            <div class="col-sm-12">
                <div class="btn-group pull-right m-t-15">
                    <form method="post" action="<?php echo base_url(); ?>programs_controller/program_invoice_add/<?php echo $id_program_enrollment;?>">
                        <input type="hidden" name="csrf_test_name" id="invoices_add_csrf" value=""/>
                        <button type="submit" onclick="$('#invoices_add_csrf').val($('#cook').val());" class="btn btn-custom waves-effect waves-light" >New Invoice<span class="m-l-5"><i class="fa fa-plus"></i></span></button>
                    </form>
                </div>
                <h4 class="page-title">Invoices For (<?php echo $invoices[0]['customer_name'];?>):</h4>
            </div>
        </div>
         
        <div class="row">

            <div class="card-box">
                <div class="row">
                    <table class="table table-striped table-resposive">
                        <thead>
                            <th>Invoice ID</th>
                            <th>Invoice #</th>
                            <th>Payment Date</th>
                            <th>Payment Mode</th>
                            <th style="text-align: right;">Paid Amount</th>
                            <th >Action</th>
                            <th></th>
                        </thead>
                        <tbody>
                            <?php $totalpaid=0; foreach($invoices as $invoice){?>
                            <tr>
                                <td><?php echo $invoice['id_program_invoices'];?></td>
                                <td><?php echo $invoice['invoice_number'];?></td>
                                <td><?php echo $invoice['f_payment_date'];?></td>
                                <td><?php echo $invoice['payment_mode'];?></td>
                                <td style="text-align: right;"><?php echo $invoice['paid_amount']; $totalpaid+=$invoice['paid_amount'];?></td>
                                <td><form method="post" action="<?php echo base_url().'programs_controller/program_invoice_cancel' ;?>">
                                        <input name="invoiceid" type="hidden" value="<?php echo $invoice['id_program_invoices'];?>">
                                        <input name="enrollmentid" type="hidden" value="<?php echo $invoice['id_program_enrollment'];?>">
                                        <button type="submit" class="btn btn-danger"><i class="fa fa-trash"></i> Cancel</button>
                                    </form>
                                </td>                                
                                <td><a class="btn btn-pink" href="<?php echo base_url().'print_program_invoice/'.$invoice['id_program_enrollment'] ;?>" ><i class="fa fa-print"></i> Print</a></td>
                                
                            </tr>    
                            
                            <?php } ?>
                        </tbody>
                        <tfoot>
                            <th colspan="4"></th>
                            <th style="text-align: right;"><?php echo $totalpaid;?></th>
                            <th></th>
                            <th></th>
                        </tfoot>
                    </table>
                </div>
            </div>

        </div>
    
    </div>