<?php
$l = $level->listlevel();
?>
<div class="page-content">
    <div class="row">
        <div class="col-xs-12">
            <div class="row">
                <div class="col-xs-12">
                    <h3 class="header smaller lighter blue">Level Otoritas</h3>
                    <div class="clearfix">
                        <a href="#modal-form" role="button" class="blue" data-toggle="modal">
                            <button class="btn btn-white btn-info btn-bold">
                                <i class="ace-icon fa fa-plus bigger-120 blue"></i>
                                Tambah
                            </button>
                        </a>
                        <div class="pull-right tableTools-container"></div>
                    </div>
                    <div>
                        <table id="dynamic-table" class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>Level</th>
                                    <th>Status</th>
                                    <th></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                    while($i<count($l)){
                                ?>
                                        <tr>
                                            <td><?php echo $l[$i][level]; ?></td>
                                            <td>
                                                <?php if($l[$i][aktif]=='Y'){ ?>
                                                    <span class="label label-success">Aktif</span>
                                                <?php }else{ ?>    
                                                    <span class="label label-danger">Tidak Aktif</span>
                                                <?php } ?>
                                            </td>
                                            <td>
                                                <div class="hidden-sm hidden-xs action-buttons">
                                                    <a class="green" href="index.php?module=otoritas&act=edit&id=<?php echo"".$l[$i][id_level].""; ?>">
                                                        <i class="ace-icon fa fa-pencil bigger-130"></i>
                                                    </a>
                                                    <a class="red" href="view/view/modul/mod_otoritas/aksi_otoritas.php?aksi=delete&id=<?php echo"".$l[$i][id_level].""; ?>">
                                                        <i class="ace-icon fa fa-trash-o bigger-130"></i>
                                                    </a>
                                                </div>
                                            </td>
                                        </tr>
                                <?php
                                        $i++;
                                    }
                                    unset($i);
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div><!-- /.col -->
    </div><!-- /.row -->
    <div id="modal-form" class="modal" tabindex="-1">
        <div class="modal-dialog">
            <form class="form-horizontal" role="form" action="view/view/modul/mod_otoritas/aksi_otoritas.php?aksi=tambah" method="post" >
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h4 class="blue bigger">Tambah Level Otoritas</h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-xs-12 col-sm-12">
                                    <div class="form-group">
                                        <label> Nama Level </label>
                                        <div>
                                            <input type="text" id="form-field-1" class="form-control" placeholder="Nama Level" name="nama" />
                                        </div>
                                    </div>

                                    <div class="space-4"></div>

                                    <div class="form-group">
                                        <label> Aktif </label>
                                        <div>
                                            <select id="form-field-1" class="form-control" name="aktif">
                                                <option value=""></option>
                                                <option value="Y">Ya</option>
                                                <option value="N">Tidak</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="space-4"></div>

                                    <div>
                                        <table id="dynamic-table" class="table table-striped table-bordered table-hover">
                                            <thead>
                                                <tr>
                                                    <th></th>
                                                    <th>Menu</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                    $m = $menu->menu('admin','','admin');
                                                    $no = 1;
                                                    while($i<count($m)){
                                                ?>
                                                        <tr>
                                                            <td><input type="hidden" name="<?php echo check.$no; ?>" value="<?php echo $m[$i][id]; ?>" /></td>
                                                            <td>
                                                                <b><?php echo $m[$i][nama]; ?></b>    
                                                            </td>
                                                        </tr>
                                                        <?php
                                                        $s = $menu->submenu($m[$i][id],'','admin');
                                                        $nos=1;
                                                        while($n<count($s)){
                                                        ?>
                                                            <tr>
                                                                <td><input type="checkbox" name="<?php echo check.$no.$nos; ?>" value="<?php echo $s[$n][id]; ?>" /></td>
                                                                <td>
                                                                    <b><?php echo $s[$n][nama]; ?></b>    
                                                                </td>
                                                            </tr>
                                                        <?php    
                                                            $n++; 
                                                            $nos++;
                                                        }
                                                        unset($n);
                                                        
                                                        $i++;
                                                        $no++;
                                                    }
                                                    unset($i);
                                                ?>
                                            </tbody>
                                        </table>
                                    </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-sm" data-dismiss="modal">
                        <i class="ace-icon fa fa-times"></i>
                        Cancel
                    </button>
                    <button class="btn btn-sm btn-primary" type="submit">
                        <i class="ace-icon fa fa-check"></i>
                        Save
                    </button>
                </div>
            </form> 
        </div>
    </div>
</div><!-- PAGE CONTENT ENDS -->
</div><!-- /.page-content -->