<!-- Begin Page Content -->
<div class="container-fluid">

    <!-- Page Heading -->
    <h1 class="h3 mb-4 text-gray-800"><?= $title;  ?></h1>

	<div class="row mt-3 mb-4">
		<div class="col-sm">
			<div class="card border-bottom-primary shadow mb-4">
	            <div class="card-header py-3">
	              <h6 class="m-0 font-weight-bold text-primary">Tabel Neraca Saldo</h6>
	            </div>
			  	<div class="card-body">
				  	<div class="row">
				  		<div class="col-sm">
				  			<div class="table-responsive">
					  			<table class="table table-striped table-sm" style="width:100%" id="tabel-data">
								  <thead>
                    <tr>
                      <th scope="col" width="80px" rowspan="2">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" colspan="2" class="text-center">Saldo Akhir</th>
                    </tr>
								    <tr>
                      <th scope="col" width="150px">Debit</th>
                      <th scope="col" width="150px">Kredit</th>
                      <th scope="col" width="150px">Debit</th>
                      <th scope="col" width="150px">Kredit</th>
								    </tr>
								  </thead>
								  <tbody>
 
                    <!-- Aset Lancar -->
                      <?php 
                            $sum_aset_lancar_debit_awal = 0;
                            $sum_aset_lancar_kredit_awal = 0;
                            $sum_aset_lancar_debit = 0;
                            $sum_aset_lancar_kredit = 0;
                            if(isset($neraca_saldo_data[0][110]))
                            {
                                foreach ($neraca_saldo_data[0][110] as $key => $row)
                                {
                        ?>
                                    <tr>
                                        <td align="center"><?= $row['noakun'] ?></td>
                                        <td><?= $row['nama'] ?></td>
                                      <?php if($row['saldo_awal'] >= 0) { ?>
                                          <td align="right"><?= 'Rp. '.number_format($row['saldo_awal'],0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_aset_lancar_debit_awal += $row['saldo_awal']; ?>
                                      <?php } else { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                          <?php $sum_aset_lancar_kredit_awal += $row['saldo_awal']; ?>
                                      <?php } ?>
                                      <?php if($row['saldo'] >= 0) { ?>
                                          <td align="right"><?= 'Rp. '.number_format($row['saldo'],0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_aset_lancar_debit += $row['saldo']; ?>
                                      <?php } else { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                          <?php $sum_aset_lancar_kredit += $row['saldo']; ?>
                                      <?php } ?>
                                    </tr>
                        <?php 
                                }
                            }
                         ?>
                         <!-- Tutup Aset Lancar -->
                         <!-- Aset Tetap -->
                         <?php 
                            $sum_aset_tetap_debit_awal = 0;
                            $sum_aset_tetap_kredit_awal = 0;
                            $sum_aset_tetap_debit = 0;
                            $sum_aset_tetap_kredit = 0;
                            if(isset($neraca_saldo_data[0][120]))
                            {
                                foreach ($neraca_saldo_data[0][120] as $key => $row)
                                {
                        ?>
                                    <tr>
                                        <td align="center"><?= $row['noakun'] ?></td>
                                        <td><?= $row['nama'] ?></td>
                                          <?php if($row['saldo_awal'] >= 0) { ?>
                                              <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                              <td></td>
                                              <?php $sum_aset_tetap_debit_awal += $row['saldo_awal']; ?>
                                          <?php } else { ?>
                                              <td></td>
                                              <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                              <?php $sum_aset_tetap_kredit_awal += $row['saldo_awal']; ?>
                                          <?php } ?>
                                          <?php if($row['saldo'] >= 0) { ?>
                                              <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                              <td></td>
                                              <?php $sum_aset_tetap_debit += $row['saldo']; ?>
                                          <?php } else { ?>
                                              <td></td>
                                              <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                              <?php $sum_aset_tetap_kredit += $row['saldo']; ?>
                                          <?php } ?>
                                    </tr>
                        <?php 
                                }
                            }
                         ?>
                         <!-- tutup aset tetap -->
                         <!-- liabilitas jangka pendek -->
                         <?php 
                            $sum_liabilitas_jangka_pendek_debit_awal = 0;
                            $sum_liabilitas_jangka_pendek_kredit_awal = 0;
                            $sum_liabilitas_jangka_pendek_debit = 0;
                            $sum_liabilitas_jangka_pendek_kredit = 0;
                            if(isset($neraca_saldo_data[0][210]))
                            {
                                foreach ($neraca_saldo_data[0][210] as $key => $row)
                                {
                        ?>
                                    <tr>
                                        <td align="center"><?= $row['noakun'] ?></td>
                                        <td><?= $row['nama'] ?></td>
                                      <?php if($row['saldo_awal'] <= 0) { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                          <?php $sum_liabilitas_jangka_pendek_debit_awal += $row['saldo_awal']; ?>
                                      <?php } else { ?>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_liabilitas_jangka_pendek_kredit_awal += $row['saldo_awal']; ?>
                                      <?php } ?>
                                      <?php if($row['saldo'] <= 0) { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                          <?php $sum_liabilitas_jangka_pendek_kredit += $row['saldo']; ?>
                                      <?php } else { ?>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_liabilitas_jangka_pendek_debit += $row['saldo']; ?>
                                      <?php } ?>
                                    </tr>
                        <?php 
                                }
                            }
                         ?>
                         <!-- tutup liabilitas jangka pendek -->
                         <!-- liabilitas jangka panjang -->
                         <?php 
                            $sum_liabilitas_jangka_panjang_debit_awal = 0;
                            $sum_liabilitas_jangka_panjang_kredit_awal = 0;
                            $sum_liabilitas_jangka_panjang_debit = 0;
                            $sum_liabilitas_jangka_panjang_kredit = 0;
                            if(isset($neraca_saldo_data[0][220]))
                            {
                                foreach ($neraca_saldo_data[0][220] as $key => $row)
                                {
                        ?>
                                    <tr>
                                        <td align="center"><?= $row['noakun'] ?></td>
                                        <td><?= $row['nama'] ?></td>
                                      <?php if($row['saldo_awal'] >= 0) { ?>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_liabilitas_jangka_panjang_debit_awal += $row['saldo_awal']; ?>
                                      <?php } else { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                          <?php $sum_liabilitas_jangka_panjang_kredit_awal += $row['saldo_awal']; ?>
                                      <?php } ?>
                                      <?php if($row['saldo'] >= 0) { ?>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_liabilitas_jangka_panjang_debit += $row['saldo']; ?>
                                      <?php } else { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                          <?php $sum_liabilitas_jangka_panjang_kredit += $row['saldo']; ?>
                                      <?php } ?>
                                    </tr>
                        <?php 
                                }
                            }
                         ?>
                         <!-- tutup liabilitas jngaka panjang -->
                         <!-- ekuitas -->
                         <?php 
                            $sum_ekuitas_debit_awal = 0;
                            $sum_ekuitas_kredit_awal = 0;
                            $sum_ekuitas_debit = 0;
                            $sum_ekuitas_kredit = 0;
                            if(isset($neraca_saldo_data[0][310]))
                            {
                                foreach ($neraca_saldo_data[0][310] as $key => $row)
                                {
                        ?>
                                  <tr>
                                        <td align="center"><?= $row['noakun'] ?></td>
                                        <td><?= $row['nama'] ?></td>
                                      <?php if($row['saldo_awal'] >= 0) { ?>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_ekuitas_debit_awal += $row['saldo_awal']; ?>
                                      <?php } else { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                          <?php $sum_ekuitas_kredit_awal += $row['saldo_awal']; ?>
                                      <?php } ?>
                                      <?php if($row['saldo'] >= 0) { ?>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_ekuitas_debit += $row['saldo']; ?>
                                      <?php } else { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                          <?php $sum_ekuitas_kredit += $row['saldo']; ?>
                                      <?php } ?>
                                    </tr>
                        <?php
                                }
                            }
                         ?>
                         <!-- tutup ekuitas -->
                         <!-- pendapatan operasional -->
                         <?php 
                          $sum_pendapatan_operasional_debit_awal = 0;
                          $sum_pendapatan_operasional_kredit_awal = 0;
                          $sum_pendapatan_operasional_debit = 0;
                          $sum_pendapatan_operasional_kredit = 0;
                            if(isset($neraca_saldo_data[0][410]))
                            {
                                foreach ($neraca_saldo_data[0][410] as $key => $row)
                                {
                        ?>
                                    <tr>
                                        <td align="center"><?= $row['noakun'] ?></td>
                                        <td><?= $row['nama'] ?></td>
                                      <?php if($row['saldo_awal'] >= 0) { ?>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_pendapatan_operasional_debit_awal += $row['saldo_awal']; ?>
                                      <?php } else { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                          <?php $sum_pendapatan_operasional_kredit_awal += $row['saldo_awal']; ?>
                                      <?php } ?>
                                      <?php if($row['saldo'] >= 0) { ?>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_pendapatan_operasional_debit += $row['saldo']; ?>
                                      <?php } else { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                          <?php $sum_pendapatan_operasional_kredit += $row['saldo']; ?>
                                      <?php } ?>
                                    </tr>
                        <?php 
                                }
                            }
                         ?>
                         <!-- tutup pendapatan operasional -->
                         <!-- pendapatan non-operasional -->
                         <?php 
                          $sum_pendapatan_nonoperasional_debit_awal = 0;
                          $sum_pendapatan_nonoperasional_kredit_awal = 0;
                          $sum_pendapatan_nonoperasional_debit = 0;
                          $sum_pendapatan_nonoperasional_kredit = 0;
                            if(isset($neraca_saldo_data[0][420]))
                            {
                                foreach ($neraca_saldo_data[0][420] as $key => $row)
                                {
                        ?>
                                    <tr>
                                        <td align="center"><?= $row['noakun'] ?></td>
                                        <td><?= $row['nama'] ?></td>
                                      <?php if($row['saldo_awal'] >= 0) { ?>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_pendapatan_nonoperasional_debit_awal += $row['saldo_awal']; ?>
                                      <?php } else { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                          <?php $sum_pendapatan_nonoperasional_kredit_awal += $row['saldo_awal']; ?>
                                      <?php } ?>
                                      <?php if($row['saldo'] >= 0) { ?>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_pendapatan_nonoperasional_debit += $row['saldo']; ?>
                                      <?php } else { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                          <?php $sum_pendapatan_nonoperasional_kredit += $row['saldo']; ?>
                                      <?php } ?>
                                    </tr>
                        <?php 
                                }
                            }
                         ?>
                         <!-- tutup pendapatan non-operasional -->
                         <!-- beban operasional -->
                         <?php 
                            $sum_beban_operasional_debit_awal = 0;
                            $sum_beban_operasional_kredit_awal = 0;
                            $sum_beban_operasional_debit = 0;
                            $sum_beban_operasional_kredit = 0;
                            if(isset($neraca_saldo_data[0][510]))
                            {
                                foreach ($neraca_saldo_data[0][510] as $key => $row)
                                {
                        ?>
                                    <tr>
                                        <td align="center"><?= $row['noakun'] ?></td>
                                        <td><?= $row['nama'] ?></td>
                                      <?php if($row['saldo_awal'] >= 0) { ?>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_beban_operasional_debit_awal += $row['saldo_awal']; ?>
                                      <?php } else { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                          <?php $sum_beban_operasional_kredit_awal += $row['saldo_awal']; ?>
                                      <?php } ?>
                                      <?php if($row['saldo'] >= 0) { ?>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                          <td></td>
                                          <?php $sum_beban_operasional_debit += $row['saldo']; ?>
                                      <?php } else { ?>
                                          <td></td>
                                          <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                          <?php $sum_beban_operasional_kredit += $row['saldo']; ?>
                                      <?php } ?>
                                    </tr>
                        <?php 
                                }
                            }
                         ?>
                         <!-- tutup beban operasional -->
                         <!-- beban non operasional -->
                         <?php 
                          $sum_beban_nonoperasional_debit_awal = 0;
                          $sum_beban_nonoperasional_kredit_awal = 0;
                          $sum_beban_nonoperasional_debit = 0;
                          $sum_beban_nonoperasional_kredit = 0;
                            if(isset($neraca_saldo_data[0][520]))
                            {
                                foreach ($neraca_saldo_data[0][520] as $key => $row)
                                {
                        ?>
                                    <tr>
                                        <td align="center"><?= $row['noakun'] ?></td>
                                        <td><?= $row['nama'] ?></td>
                                        <?php if($row['saldo_awal'] >= 0) { ?>
                                              <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                              <td></td>
                                              <?php $sum_beban_nonoperasional_debit_awal += $row['saldo_awal']; ?>
                                        <?php } else { ?>
                                              <td></td>
                                              <td align="right"><?= 'Rp. '.number_format(abs($row['saldo_awal']),0,',','.') ?></td>
                                              <?php $sum_beban_nonoperasional_kredit_awal += $row['saldo_awal']; ?>
                                        <?php } ?>
                                        <?php if($row['saldo'] >= 0) { ?>
                                              <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                              <td></td>
                                              <?php $sum_beban_nonoperasional_debit += $row['saldo']; ?>
                                        <?php } else { ?>
                                              <td></td>
                                              <td align="right"><?= 'Rp. '.number_format(abs($row['saldo']),0,',','.') ?></td>
                                              <?php $sum_beban_nonoperasional_kredit += $row['saldo']; ?>
                                        <?php } ?>
                                    </tr>
                        <?php 
                                }
                            }
                         ?>
                         <!-- tutup beban non operasional -->
               
                  </tbody>
                  <tfoot>
            
                         <!-- jumlah -->
                         <?php $sum_debit_awal = $sum_aset_lancar_debit_awal + $sum_aset_tetap_debit_awal + $sum_liabilitas_jangka_pendek_debit_awal + $sum_liabilitas_jangka_panjang_debit_awal + $sum_ekuitas_debit_awal + $sum_pendapatan_operasional_debit_awal + $sum_pendapatan_nonoperasional_debit_awal + $sum_beban_operasional_debit_awal + $sum_beban_nonoperasional_debit_awal; ?>
                         <?php $sum_kredit_awal = $sum_aset_lancar_kredit_awal + $sum_aset_tetap_kredit_awal + $sum_liabilitas_jangka_pendek_kredit_awal + $sum_liabilitas_jangka_panjang_kredit_awal + $sum_ekuitas_kredit_awal + $sum_pendapatan_operasional_kredit_awal + $sum_pendapatan_nonoperasional_kredit_awal + $sum_beban_operasional_kredit_awal + $sum_beban_nonoperasional_kredit_awal; ?>
                         <?php $sum_debit = $sum_aset_lancar_debit + $sum_aset_tetap_debit + $sum_liabilitas_jangka_pendek_debit + $sum_liabilitas_jangka_panjang_debit + $sum_ekuitas_debit + $sum_pendapatan_operasional_debit + $sum_pendapatan_nonoperasional_debit + $sum_beban_operasional_debit + $sum_beban_nonoperasional_debit; ?>
                         <?php $sum_kredit = $sum_aset_lancar_kredit + $sum_aset_tetap_kredit + $sum_liabilitas_jangka_pendek_kredit + $sum_liabilitas_jangka_panjang_kredit + $sum_ekuitas_kredit + $sum_pendapatan_operasional_kredit + $sum_pendapatan_nonoperasional_kredit + $sum_beban_operasional_kredit + $sum_beban_nonoperasional_kredit; ?>
                         <tr style="font-weight:bold;">
                            <td colspan="2" align="center">Jumlah</td>
                            <td class="text-primary" align="right"><?= 'Rp. '.number_format($sum_debit_awal,0,',','.') ?></td>
                            <td class="text-primary" align="right"><?= 'Rp. '.number_format(abs($sum_kredit_awal),0,',','.') ?></td>
                            <td class="text-primary" align="right"><?= 'Rp. '.number_format($sum_debit,0,',','.') ?></td>
                            <td class="text-primary" align="right"><?= 'Rp. '.number_format(abs($sum_kredit),0,',','.') ?></td>
                        </tr>
           

                  </tfoot>
								</table>
							</div>
				  		</div>
				  	</div>
			  	</div>
			</div>
		</div>
	</div>

</div>
<!-- /.container-fluid -->

</div>
<!-- End of Main Content --> 
