<?php function buatrp($angka) { $jadi = "" . number_format($angka,0,',','.'); return $jadi; } ?>
<div class="row">
    <div class="col-md-12">
        <div class="box">
            <div class="box-header with-border">
                <h3 class="box-title"><?php echo $title." Tahun ".date('Y'); ?></h3>
                <div class="box-tools pull-right">
                    <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                    <a href="<?php echo base_url('admin/home'); ?>" class="btn btn-box-tool"><i class="fa fa-times"></i></a>
                </div>
            </div>
            <div class="box-body">
                <div class="form-group margin">
                    <label class="req">Periode</label>
                    <div class="input-group">
                        <!-- <div class="input-group-addon"><i class="fa fa-calendar"></i></div> -->
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-info btn-flat" onclick="lihat();">Lihat</button>
                        </span>
                        <input class="form-control" id="tanggal" name="tanggal" type="text" data-date-format="yyyy-mm" value="<?php echo date('Y').'-'.date('m') ?>">
                    </div>
                </div>
                
                <?php if(count($data) == 0) { ?>
                    <h4>Periode : <?php echo ConvertBulan(date('m'))." ".date('Y'); ?></h4>
                <?php } else { ?>
                    <h4>Periode : <?php echo ConvertBulan($this->uri->segment(3))." ".$this->uri->segment(4); ?></h4>
                <?php } ?>

                <div class="table-responsive">
                    <table class="table table-hover table-bordered">
                        <thead>
                            <tr>
                                <th><center>Kategori</center></th>
                                <th><center>No</center></th>
                                <th><center>Judul Indikator</center></th>
                                <th><center>Standar</center></th>
                                <th><center>Bobot</center></th>
                                <th><center>Haper</center></th>
                                <th><center>Skor</center></th>
                                <th><center>Total</center></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if(count($data) == 0) { ?>
                                <tr>
                                    <td colspan="8"><center><h4>Belum Ada Data</h4></center></td>
                                </tr>
                            <?php } else { ?>
                            <?php $i = 1; $total = 0; foreach ($data as $row) { ?>
                                <tr>
                                    <td><?php echo $row->KategoriDesc; ?></td>
                                    <td align="center"><?php echo $i; ?></td>
                                    <td><?php echo $row->Indikator; ?></td>
                                    <td align="center"><?php echo $row->Sign." ".number_format($row->Standard, 2, ".", ".")." ".$row->Satuan; ?></td>
                                    <td align="center"><?php echo number_format($row->Bobot, 2, ".", "."); ?></td>
                                    <td align="center"><?php echo number_format($row->Haper, 2, ".", "."); ?></td>
                                    <td align="center"><?php echo number_format($row->Skor, 2, ".", "."); ?></td>
                                    <td align="center"><?php echo number_format($row->Total, 2, ".", "."); ?></td>
                                    <?php $total += $row->Total; ?>
                                </tr>
                            <?php $i++; }} ?>

                            <?php if(count($data) == 0) { echo ""; } else { ?>
                                <tr>
                                    <th colspan="7"><center>Jumlah TS</center></th>
                                    <th align="center"><center><?php echo number_format($total, 2, ".", "."); ?></center></th>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="box-footer">
                <i class="fa fa-clock-o"></i> Data realtime
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $('#tanggal').datepicker({
            autoclose: true,
            format: "yyyy-mm",
            startView: 'months',
            minViewMode: 'months',
        });
    });

    function lihat() {
        var periode = document.getElementById('tanggal').value;
        var pisah = periode.split("-");
        var bln = pisah[1];
        var thn = pisah[0];
        window.location.assign("<?php echo base_url('admin/iki'); ?>"+"/"+bln+"/"+thn);
    }
</script>