<div class="m-portlet m-portlet--mobile">
    <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
            <div class="m-portlet__head-title">
                <h3 class="m-portlet__head-text">
                    Daftar Tagihan Peserta
                </h3>
            </div>
        </div>
        
    </div>
    <div class="m-portlet__body">
        <?php
            if ($this->session->userdata('alert_error') != NULL) {
                $alert_error = $this->session->userdata('alert_error');
                $alert_error_type = $this->session->userdata('alert_error_type');

                echo '
                    <div class="m-alert m-alert--icon m-alert--air m-alert--square alert '.$alert_error_type.' alert-dismissible fade show" role="alert" >
                        <div class="m-alert__icon">
                            <i class="la la-warning"></i>
                        </div>
                        <div class="m-alert__text">
                            '.$alert_error.'
                        </div>
                        <div class="m-alert__close">
                            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            </button>
                        </div>
                    </div>
                ';

                $this->session->unset_userdata('alert_error');
                $this->session->unset_userdata('alert_error_type');
            }
        ?>
        <div class="form-group m-form__group row">
            <div class="col-lg-5" >
                <table width="100%" style="font-size: 14px;">
                    
                    <tr>
                        <td >No Identitas</td>
                        <td align="center">:</td>
                        <td><?php echo $peserta["no_identitas"]; ?></td>
                    </tr>

                    <tr>
                        <td>Nama Lengkap</td>
                        <td align="center">:</td>
                        <td><?php echo $peserta["nama_lengkap"]; ?></td>
                    </tr>

                    <tr>
                        <td>Jenis Kelamin</td>
                        <td align="center">:</td>
                        <td><?php echo jk($peserta["jenis_kelamin"]); ?></td>
                    </tr>

                    <tr>
                        <td>Kelas</td>
                        <td align="center">:</td>
                        <td><?php echo $peserta["tingkat"]."-".$peserta["kelas"]; ?></td>
                    </tr>

                    
                </table>
            </div>
            <div class="col-lg-4" >&nbsp;</div>
            <div class="col-lg-3" >
               &nbsp;
            </div>
        </div>

        <div class="table-responsive">
            <table class="table table-striped table-bordered table-hover table-checkable m-datatable--brand" id="m_table_1" style="width:99.9%;">
                <thead class="btn-brand">
                    <tr>
                        <th class="text-center" width="50px">#</th>
                        <th class="text-left">Nama Tagihan</th>
                        <th class="text-center" width="50px">Tipe</th>
                        <th class="text-right" width="140px">Nominal</th>
                        <th class="text-right" width="140px">Sudah Dibayar</th>
                        <th class="text-center" width="120px">Sisa Bayar</th>
						<th class="text-center" width="140px">Status</th>
						<th class="text-center" width="100px">Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                        $total_nominal = 0;
                        $total_bayar = 0;

                        if (count($tagihan) > 0) {

                            $status_total = "";
                            $status_tagihan = "";
                            $no=1;
                            foreach ($tagihan as $row_tagihan) {
                                $sudah_dibayar = $this->superuser_model->rincianCek($peserta["peserta_id"], $row_tagihan["tagihan_peserta_id"]);

                                if($row_tagihan["nominal"] == $sudah_dibayar){
                                    $status_tagihan = '<span class="m-badge m-badge--success m-badge--wide">sudah lunas</span>';
									$buttonaksi='-';
                                }else{
                                    $status_tagihan = '<span class="m-badge m-badge--danger m-badge--wide">belum lunas</span>';
									$buttonaksi='<a href="'.base_url('siswa/bayar/'.$row_tagihan["tagihan_peserta_id"]).'" class="btn btn-primary btn-sm">Bayar</a>';
                                }

                                echo '
                                    <tr>
                                        <td class="text-center">'.$no.'</td>
                                        <td class="text-left">'.$row_tagihan["nama_tagihan"].' ('.bulan($row_tagihan["bulan"]).' '.$row_tagihan["tahun"].')</td>
                                        <td class="text-center">'.$row_tagihan["tipe_tagihan"].'</td>
                                        <td class="text-right">'.rupiah($row_tagihan["nominal"]).'</td>
                                        <td class="text-right">'.rupiah($sudah_dibayar).'</td>
                                        <td class="text-center">'.rupiah($row_tagihan["nominal"] - $sudah_dibayar).'</td>
										<td class="text-center">'.$status_tagihan.'</td>
										<td class="text-center">'.$buttonaksi.'</td>
                                    </tr>
                                ';

                                $total_nominal += $row_tagihan["nominal"];
                                $total_bayar += $sudah_dibayar;
                                $no++;
                            }

                            if($total_nominal == $total_bayar){
                                $status_total = '<span class="m-badge m-badge--success m-badge--wide">sudah lunas</span>';
                            }else{
                                $status_total = '<span class="m-badge m-badge--danger m-badge--wide">belum lunas</span>';
                            }
                        }else{
                            echo "<tr><td align='center' colspan='10'>Belum ada tagihan.</td></tr>";
                            $no = 0;
                        }
                    ?>

                </tbody>
                <?php $total_diskon = $this->superuser_model->getDiskon($peserta["peserta_id"]); ?>
                
                <thead style="border-top: 2px dashed #b2bec3;">
                    <tr>
                        <th class="text-center" colspan="3"><strong>TOTAL</strong></th>
                        <th class="text-right"><?php echo rupiah($total_nominal); ?></th>
                        <th class="text-right"><?php echo rupiah($total_bayar); ?></th>
                        <th class="text-center"><?php echo rupiah($total_nominal - $total_bayar); ?></th>
                    </tr>
                </thead>
                
            </table>

            
        </div>

    </div>
</div>
<!-- END EXAMPLE TABLE PORTLET-->

