<div class="table-responsive">
	<table class="table table-dataAkun table-striped table-bordered table-sm" id="tabel-data">
		<thead>
			<tr>
				<th scope="col" rowspan="2" width="2%">No.</th>
				<th scope="col" rowspan="2">Kelompok Akun</th>
				<th scope="col" rowspan="2" width="10%">No Akun</th>
				<th scope="col" rowspan="2">Nama Akun</th>
				<th scope="col" colspan="2" class="text-center">Saldo Awal</th>
				<th scope="col" rowspan="2">Action</th>
			</tr>
			<tr>
				<th scope="col" width="15%">Debit</th>
				<th scope="col" width="15%">Kredit</th>
			</tr>
		</thead>
		<tbody>
			<?php $i=$this->uri->segment(3)+1; ?>
			<?php $total_debit = 0; ?>
			<?php $total_kredit = 0; ?>
			<?php 
				if(!empty($masterdata)){
				foreach ($masterdata as $md) : ?>
				<tr>
					<th scope="row"><?= $i++; ?></th>
					<td><?= $md['nama_kel_akun']; ?></td>
					<td class="text-left"><?= $md['noakun']; ?></td>
					<td ><?= $md['nama']; ?></td>
					<?php 
						if ($md['id_perkiraan'] == 1) {
						?>
						<td align="right"><?= 'Rp. '.number_format($md['saldo_awal'],0,',','.') ?></td>
						<td></td>
						<?php $total_debit += $md['saldo_awal']; ?>
						<?php  
							} else {
						?>
						<td></td>
						<td align="right"><?= 'Rp. '.number_format($md['saldo_awal'],0,',','.') ?></td>
						<?php $total_kredit += $md['saldo_awal']; ?>
						<?php  
						}
					?>
					
					<td class="text-center" width="15%">
						<div class='btn-group btn-group-sm' role='group'>
							<a href="<?= base_url(); ?>masterdata/edit/<?= encrypt_url($md['id_akun']); ?>" class="btn btn-primary">
								<span class="icon text-white-50">
									<i class="fa fa-fw fa-edit"></i>
								</span>
								<span class="text">Edit</span>
							</a>
							<button type='button' data-toggle='modal'  class='btn btn-danger btn-sm modal_hapus_akun flat' data-id='<?=encrypt_url($md['id_akun']);?>'><i class='fa fa-trash'></i> Hapus</button>
						</div>
					</td>
				</tr>
				<?php endforeach; 
				}
			?>
		</tbody>
		<tfoot>
			<tr>
				<th colspan="4" class="text-right">Total</th>
				<th><?= 'Rp. '.number_format($total_debit,0,',','.') ?></th>
				<th><?= 'Rp. '.number_format($total_kredit,0,',','.') ?></th>
				
				<th></th>
				
			</tr>
		</tfoot>
	</table>
	<nav aria-label="Page navigation" class="mt-2">
		<?php 
			echo $this->ajax_pagination->create_links(); 
		?>
	</nav>
</div><!-- /.card-body -->
