<?php
//open form
echo form_open( base_url( 'invoice/tambah' ), ' class="form-horizontal"' );

?>

<p>
<?php if($this->session->userdata('level')=="Administrator" or ($this->session->userdata('level')=="Operator")) { ?>
    
    <button type   = "button" class="btn btn-info" data-toggle="modal" data-target="#modal-default">
		  <i class    = "fa fa-plus"></i> Invoice
	</button>
    <!-- <a class       = 'btn btn-primary' href = "<?php echo base_url('invoice/export') ?>" onclick = "return confirm('Yakin ingin mengexport data invoice ke excel ?')"><i class = 'fa fa-file-excel'></i> Export Excel</a> -->
    <?php }
    ?>
    <a href        = "<?php echo base_url('dashboard') ?>" class = 'btn btn-secondary' data-dismiss = 'modal'><i class = 'fa fa-times'></i> Kembali</a>
    </p>

    <?php
    //panggil form tambah
    include( 'tambah.php' );
    //closing form
    echo form_close();
    ?>
    <table class    = 'table table-bordered table-striped table-sm' id = 'example9'>
    <thead>
    <tr>
    <th width    = '5%'>NO</th>
    <th width    = '8%'>NO. PEND</th>
    <th width    = '8%'>TGL. Invoice</th>
    <th width    = '20%'>NAMA LENGKAP</th>
    <th width    = '25%'>SEKOLAH ASAL</th>
    <th width    = '10%'>KOMP<span class="hide-on-export">/GEL</span></th>
    <th width    = '10%'>GEL</th>
    <th width    = '10%'>BIAYA PPDB</th>
    <th width    = '10%'>POT. GEL</th>
    <th width    = '10%'>POT. DP</th>
    <th width    = '10%'>POT. YATIM</th>
    <th width    = '10%'>POT. SPP</th>
    <th width    = '10%'>POT. KEMBAR</th>
    <th width    = '10%'>POT. YAYASAN</th>
    <th width    = '10%'>POT. SKTM</th>
    <th width    = '30%'>POT. LAIN</th>
    <th width    = '30%'>KETENTUAN DIBAYARKAN</th>
    <th width    = '30%'>AKSI</th>
    </tr>
    </thead>
    <tbody>
    <?php foreach ( $invoice as $key => $invoice ) {
        ?>

        <tr>
        <td><?php echo $key+1;
        ?></td>
        <td><b><?php echo $invoice->no_pendaftaran ?></b>
        <br><small><?php echo date( 'd-m-Y', strtotime( $invoice->tgl_invoice ) ) ?></small>
        </td>
        <td><?php echo date( 'd-m-Y', strtotime( $invoice->tgl_invoice ) ) ?></td>
        <td><?php echo $invoice->nama_lengkap ?></td>
        <td><?php echo $invoice->sekolah_asal ?></td>
        <td><?php echo $invoice->kd_kompetensi ?>
        <br><small><?php echo $invoice->gelombang ?></small>
        </td>
        <td><?php echo $invoice->gelombang ?></td>
        <td><?php echo number_format( $invoice->biaya ) ?></td>
        <td><?php echo number_format( $invoice->pot_gel ) ?></td>
        <td><?php echo number_format( $invoice->pot_dp ) ?></td>
        <td><?php echo number_format( $invoice->pot_yatim ) ?></td>
        <td><?php echo number_format( $invoice->pot_spp ) ?></td>
        <td><?php echo number_format( $invoice->pot_kembar ) ?></td>
        <td><?php echo number_format( $invoice->pot_yayasan ) ?></td>
        <td><?php echo number_format( $invoice->pot_sktm ) ?></td>
        <td><?php echo number_format( $invoice->pot_lain ) ?></td>
        <td><b><?php echo number_format( $invoice->biaya - $invoice->pot_gel - $invoice->pot_dp - $invoice->pot_yatim - $invoice->pot_spp - $invoice->pot_kembar - $invoice->pot_yayasan -  $invoice->pot_sktm - $invoice->pot_lain ) ?></b></td>

        <td>
				<div class  = "btn-group">
                <a href    = "<?php echo base_url('invoice/transaksi/'.$invoice->no_pendaftaran) ?>" class="btn btn-warning btn-sm">
                <i class="fas fa-file-invoice-dollar"></i> 
					</a>
                <a href    = "<?php echo base_url('invoice/edit/'.$invoice->no_pendaftaran) ?>" class="btn btn-success btn-sm">
						<i class  = "fa fa-edit"></i>
					</a>
					
					
					<?php if($this->session->userdata('level')=="Administrator") { ?>
					<a href    = "<?php echo base_url('invoice/delete/'.$invoice->no_pendaftaran) ?>" class="btn btn-danger btn-sm" onclick="return confirm('Yakin ingin menghapus data  invoice <?php echo $invoice->nama_lengkap ?> [ <?php echo $invoice->no_pendaftaran ?> ] ..?')">
						<i class  = "fa fa-trash"></i>
					</a>
					<?php } ?>

                    
				</div>
			</td>
        </tr>

        <?php }
        ?>
        </tbody>
        </table>