<section class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <h1>
                    
                </h1>
            </div>
            <div class="col-sm-6">
                <ol class="breadcrumb float-sm-right">
                    <li class="breadcrumb-item"><a href="<?php echo base_url();?>">Dashboard</a></li>
                    <li class="breadcrumb-item"><?php echo $parent;?></li>
                    <li class="breadcrumb-item"><a href="<?php echo base_url()."index.php/".$link;?>"><?php echo $titlebefore;?></a></li>
                    <li class="breadcrumb-item active"><?php echo $title;?></li>
                </ol>
            </div>
        </div>
    </div>
</section>
<!-- Main content -->
<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <div class="card card-default">
                    <?php 
                        $setdisabled    = "";
                        $setid          = "";
                        $setnama        = "";
                        $setkode        = "";
                        $setquota       = "";
                        $setpembayaran  = "";
                        $setonline      = "";
                        $setpelayanan   = "";
                        $setstatus      = 1;
                        if ($actionform=="prosesview"){
                            $setdisabled="disabled='disabled'";
                        }
                        if ($actionform!="prosesadd"){
                            $setid          = $lkrj->row('mlrj_id');
                            $setnama        = $lkrj->row('mlrj_nama');
                            $setkode        = $lkrj->row('mlrj_kode');
                            $setquota       = $lkrj->row('mlrj_quotabangku');
                            $setpembayaran  = $lkrj->row('mlrj_pembayaran');
                            $setonline      = $lkrj->row('mlrj_online');
                            $setpelayanan   = $lkrj->row('mlrj_pelayanan');
                            $setstatus      = $lkrj->row('mlrj_status');
                        }
                    ?>
                    <form action="<?php echo(base_url()); ?>index.php/<?php echo $link;?>/<?php echo $actionform; ?>" method="post" autocomplete="off">
                        <div class="card-header">
                            <h3 class="card-title"><?php echo $title;?></h3>
                        </div>
                        <div class="card-body">
                            <?php if(validation_errors()){ ?>
                                <div id="alert" class="alert alert-danger alert-dismissable">
                                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                                    <i class="icon fa fa-ban"></i> Alert!
                                        <?php echo validation_errors() ?>
                                </div>
                                <script> 
                                    setTimeout(function() {
                                        $('#alert').hide('fast');
                                    }, 5000);
                                </script>
                            <?php } ?>
                            <div class="form-group row">
                                <label for="nama" class="col-sm-2 col-form-label">Nama</label>
                                <div class="col-sm-3">
                                    <input type="hidden" name="id" value="<?php echo $setid;?>"/>
                                    <input id="nama" name="nama" type="text" <?php echo $setdisabled;?> class="form-control" placeholder="Nama Loket" value="<?php echo $setnama;?>" />
                                </div>
                                <div class="col-sm-1">
                                    <input id="kode" name="kode" type="text" <?php echo $setdisabled;?> class="form-control" placeholder="Kode" value="<?php echo $setkode;?>" maxlength="2" style="text-transform:uppercase" />
                                </div>
                                <div class="col-sm-2">
                                    <input id="quota" name="quota" type="number" <?php echo $setdisabled;?> class="form-control" placeholder="Quota Bangku" value="<?php echo $setquota;?>" />
                                </div>
                            </div>
                            <div class="form-group row">
                                <label for="online" class="col-sm-2 col-form-label">Keterangan</label>
                                <div class="col-sm-6">
                                    <select <?php echo $setdisabled; ?> id="online" name="online" class="form-control">
                                        <option value="">Pilih Keterangan</option>
                                        <option <?php if($setonline==1){echo "selected='selected'";} ?> value="1">Online</option>
                                        <option <?php if($setonline==2){echo "selected='selected'";} ?> value="2">Offline</option>
                                        <option <?php if($setonline==3){echo "selected='selected'";} ?> value="3">Semua</option>
                                  </select>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label for="pembayaran" class="col-sm-2 col-form-label">Pembayaran</label>
                                <div class="col-sm-6">
                                    <table class="table table-sm table-bordered table-striped">
                                        <thead>
                                            <tr>
                                                <th style="width: 10px">#</th>
                                                <th>Pembayaran</th>
                                                <th style="width: 40px">Pilih</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php 
                                                $no=0;
                                                foreach($pm as $dat){
                                                    $no++;
                                                    $checkedpem = "";
                                                    $pecahpem   = explode("|",$setpembayaran);
                                                    $jumpem     = (count($pecahpem));
                                                    for($y=0;$y<=$jumpem;$y++){
                                                        if(isset($pecahpem[$y])){
                                                            if($pecahpem[$y]==$dat->mp_id){
                                                                $checkedpem = "Checked";
                                                            }
                                                        }
                                                    }
                                            ?>
                                                <tr>
                                                    <td><?php echo $no."."; ?></td>
                                                    <td><?php echo $dat->mp_nama; ?></td>
                                                    <td>
                                                        <div class="custom-control custom-checkbox">
                                                            <input <?php echo $setdisabled; echo $checkedpem;?> id="pembayaran<?php echo $no;?>" name="pembayaran[]" class="custom-control-input custom-control-input-danger custom-control-input-outline" type="checkbox" id="customCheckbox5" value="<?php echo $dat->mp_id;?>" />
                                                            <label for="pembayaran<?php echo $no;?>" class="custom-control-label"></label>
                                                        </div>
                                                    </td>
                                                </tr>
                                            
                                            <?php                                                
                                                }
                                            ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            
                            <div class="form-group row">
                                <label for="Pelayanan" class="col-sm-2 col-form-label">Pelayanan</label>
                                <div class="col-sm-6">
                                    <table class="table table-sm table-bordered table-striped">
                                        <thead>
                                            <tr>
                                                <th style="width: 10px">#</th>
                                                <th style="width: 100px">Kode</th>
                                                <th>Klinik</th>
                                                <th style="width: 40px">Pilih</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php 
                                                $no=0;
                                                foreach($kl as $dat){
                                                    $no++;
                                                    $checkedpel = "";
                                                    $pecahpel   = explode("|",$setpelayanan);
                                                    $jumpel     = (count($pecahpel));
                                                    for($y=0;$y<=$jumpel;$y++){
                                                        if(isset($pecahpel[$y])){
                                                            if($pecahpel[$y]==$dat->mk_id){
                                                                $checkedpel = "Checked";
                                                            }
                                                        }
                                                    }
                                            ?>
                                                <tr>
                                                    <td><?php echo $no."."; ?></td>
                                                    <td><?php echo $dat->mk_kode; ?></td>
                                                    <td><?php echo $dat->mk_nama; ?></td>
                                                    <td>
                                                        <label>
                                                            <div class="custom-control custom-checkbox">
                                                                <input <?php echo $setdisabled; echo $checkedpel; ?> id="pelayanan<?php echo $no;?>" name="pelayanan[]" class="custom-control-input custom-control-input-danger custom-control-input-outline" type="checkbox" id="customCheckbox5" value="<?php echo $dat->mk_id;?>" />
                                                                <label for="pelayanan<?php echo $no;?>" class="custom-control-label"></label>
                                                            </div>
                                                        </label>
                                                    </td>
                                                </tr>
                                            
                                            <?php                                                
                                                }
                                            ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            
                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label"></label>
                                <div class="col-sm-2">
                                    <input id="status" name="status" type="checkbox" value="1" <?php echo $setdisabled;?> <?php if($setstatus==1){echo "checked";}?> data-bootstrap-switch data-off-color="danger" data-on-color="success"/>
                                </div>
                            </div>
                        </div>
                        <div class="card-footer">
                            <?php if ($actionform!="prosesview"){ ?>
                                <button type="submit" class="btn btn-info">Simpan</button>
                            <?php } ?>
                            <a href="<?php echo base_url()."index.php/".$link;?>" class="btn btn-default float-right">Cancel</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</section>
