
<div class="row" id="portlet-content">
    <div class="col-md-12">
        <div class="portlet light" style="position:relative">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-laptop"></i><?=$title?>
                </div>

                <div class="actions"  style="margin-right:5px !important" >
                    <a class="btn " href="<?php echo site_url()?>/send_request_note/input">
                        <i class="fa fa-plus"></i> Request Amprahan
                    </a> 
                </div>
               

            
            </div>
            <div class="portlet-body" id="page-content" style="display:nonee">
                <div class="table-responsive">
                    <table id="<?=$controller?>_table" class="table table-bordered table-striped table-hover" style="width:100%">
                        <thead>
                            <tr>
                                <th class="text-left"><i class="fa fa-th-large"></i></th>
                                <th class="text-left">Tanggal Request</th>
                                
                                <th class="text-left">User</th>
                                <th class="text-left">Unit</th>
                                <th class="text-left">Item BHP - Qty</th>
                                <th class="text-left">Tanggal Approve</th>
                                      
                                       
                            </tr>
                        </thead>
                        <tbody>
                            <?php 
                            //echo $this->session->userdata('id_jabatan');
                            //$this->db->where('id_unit',$this->session->userdata('id_jabatan'));
                            if($this->session->userdata('id_jabatan') == '8'){
                              $this->db->where('id_unit','9');
                            }else{
                              $this->db->where('added_by',$this->session->userdata('userid'));
                            }
                            foreach ($this->M_general->select_db('bbmc_tr_amprahan_request_new')->result() as $key ) { ?>
                            <tr>  
                                <td>
                                  <?php if($key->approve == '1'){ ?>
                                  <i class="fa fa-check"></i>
                                  <?php }else{ ?>

                                  <?php if(in_array(17, $this->session->userdata('id_global_hakakses'))){ ?>
                                  <a href="<?php echo site_url()?>/request_note/setujui/<?=$key->id_amprahan_request_new?>" class="btn-xs btn-success tooltips" onclick="return confirm('Approve?');" data-toogle="m-tooltip" title="Setujui"><i class="fa fa-check"></i></a>
                                  <?php }?>
                                  <a href="<?php echo site_url()?>/send_request_note/edit/<?=$key->id_amprahan_request_new?>" class="btn-xs btn-info tooltips" data-toogle="m-tooltip" title="edit"><i class="fa fa-edit"></i></a>
                                 
                                  <a href="<?php echo site_url()?>/send_request_note/delete_request/<?=$key->id_amprahan_request_new?>" class="btn-xs btn-danger tooltips" onclick="return confirm('Anda Yakin?');" data-toogle="m-tooltip" title="edit"><i class="fa fa-times"></i></a>
                                  
                                  <?php }?>
                                </td>
                                <td><?=$key->tanggal?></td>
                                
                                <td><?=$this->M_general->get_value('bbmc_re_staff','id_re_staff',$key->added_by,'nama_staff')?></td>
                                <td><?=$this->M_general->get_value('bbmc_re_unit','id_unit',$key->id_unit,'unit');?></td>
                                <td>
                                    <?php 
                                    $this->db->where('id_amprahan_request_new',$key->id_amprahan_request_new);
                                    foreach ($this->M_general->select_db('bbmc_tr_amprahan_request_new_detail')->result() as $keyb ) { 
                                      echo $this->M_general->get_value('bbmc_re_bahan_habis_pakai','id_re_bahan_habis_pakai',$keyb->id_re_bahan_habis_pakai,'nama_item')." - @".$keyb->qty."<br>";
                                    }?>
                                </td>
                                <td><?=$key->date_approve?></td>
                               
                            </tr>
                            <?php }?>
                         

                        </tbody>
                      
                        
                    </table>
                </div>

               
            </div>
           
        </div>
    </div>
</div>





<script>
  $(document).ready( function () {
    var table=$('#<?=$controller?>_table').DataTable({
      "order": [[ 1, 'desc' ]],
      "processing": false,
      "serverSide": false,
      "searching": true,
      "language": {
            "url": "<?=base_url('media/assets/global/plugins/datatables/media/js')?>/indonesian.json"
       },
      "columnDefs": [
        
        //{"className": "text-center", "targets": [-1]},
        {"targets": [0],"bSortable": false}
      ],
    
      "fnInitComplete": function(oSettings, json) {
        $('.dataTables_processing').css('display','none');
        $( "#loading-content" ).fadeOut( "fast", function() {
          $( "#tombol-action" ).fadeIn("fast");
          $( "#page-content" ).fadeIn("fast");
        });
      }
    });

  });

  $('.hapusdata').click(function(){
    if(confirm("Apakah kamu yakin menghapus entry ini?")){
      return true;
    }
    else{
      return false;
    }
  });
</script>
