
<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>Detail Stok 
                </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">Tanggal</th>
                                <th class="text-left">Nama Item</th>
                                <th class="text-left">Stok</th>
                            </tr>
                        </thead>
                        <tbody>

                            <?php 
                            $ttl=0;

                            $this->db->select('*');
                            $this->db->from('bbmc_tr_laboratorium_penyesuaian_stok lps');
                            $this->db->where('lps.deleted','0');
                            $this->db->where('lps.id_bhp',$id_bhp);
                            $q = $this->db->get();
                            foreach ($q->result() as $key ) { ?>
                            <tr>
                              <td><?=$key->tgl?></td>
                                <td>
                                <?=$this->M_general->get_value('bbmc_re_bahan_habis_pakai','id_re_bahan_habis_pakai',$key->id_bhp,'nama_item')?>
                                 - Penyesuaian Stok Awal

                                 <a href="<?=site_url()?>/front_office/ugd_dir/ugd/laboratorium_penyesuaian_stok_update/<?=$key->id_laboratorium_penyesuaian_stok?>" style="color:blue; text-decoration: underline;">Update</a> 
                               
                                   
                                 </td>
                                <td><span style="color:red"><?=$key->qty?></span></td>
                            </tr>
                            <?php $ttl=$ttl+$key->qty;}?>


                            <?php 
                            
                            $this->db->select('*');
                            $this->db->from('bbmc_tr_amprahan a');
                            $this->db->join('bbmc_re_bahan_habis_pakai bhp','a.id_bhp = bhp.id_re_bahan_habis_pakai');
                            $this->db->where('a.deleted','0');
                            $this->db->where('a.id_unit','9');
                            $this->db->where('a.id_bhp',$id_bhp);
                            $q = $this->db->get();
                            foreach ($q->result() as $key ) { ?>
                            <tr>
                            	<td><?=$key->tgl?></td>
                                <td><?=$key->nama_item?></td>
                                <td><?=$key->stok_keluar?></td>
                            </tr>
                            <?php $ttl=$ttl+$key->stok_keluar;}?>
                            

                            <?php 
                            $this->db->select('*');
              							$this->db->from('bbmc_tr_amprahan_request_new ar');
              							$this->db->join('bbmc_tr_amprahan_request_new_detail ard','ar.id_amprahan_request_new = ard.id_amprahan_request_new');
              							$this->db->where('ar.deleted','0');
              							$this->db->where('ar.id_unit','9');
              							$this->db->where('ar.approve','1');
              							$this->db->where('id_re_bahan_habis_pakai',$id_bhp);
              							$q2 = $this->db->get();
              							foreach ($q2->result() as $key ) { ?>
                            <tr>
                            	<td><?=$key->tanggal?> </td>
                                <td><?=$this->M_general->get_value('bbmc_re_bahan_habis_pakai','id_re_bahan_habis_pakai',$key->id_re_bahan_habis_pakai,'nama_item')?> (BY REQUEST AMPRAHAN)</td>
                                <td><?=$key->qty?></td>
                            </tr>
                            <?php $ttl=$ttl+$key->qty;}?>


                            <?php 
                            $this->db->select('*');
                            $this->db->from('bbmc_tr_laboratorium_pengeluaran_stok lps');
                            $this->db->where('lps.deleted','0');
                            $this->db->where('lps.id_bhp',$id_bhp);
                            $q = $this->db->get();
                            foreach ($q->result() as $key ) { ?>
                            <tr>
                              <td><?=$key->tgl?></td>
                                <td>
                                <?=$this->M_general->get_value('bbmc_re_bahan_habis_pakai','id_re_bahan_habis_pakai',$key->id_bhp,'nama_item')?>
                                 - Pengeluaran 
                                <?php if($key->id_re_kunjungan != ''){ ?>
                                Kunjungan NO <?=$key->id_re_kunjungan?>
                                <?php }?>
                                   
                                 </td>
                                <td><span style="color:red">-<?=$key->qty?></span></td>
                            </tr>
                            <?php $ttl=$ttl-$key->qty;}?>
                            

                        </tbody>
                        <tfoot>
                          <tr>
                            <td colspan ="2"></td>
                            <td><b><?=$ttl?></b></td>
                          </tr>
                        </tfoot>
                    </table>
                </div>

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





<script>
  $(document).ready( function () {
    var table=$('#<?=$controller?>_table').DataTable({
      "order": [[ 0, 'asc' ]],
      "processing": false,
      "serverSide": false,
      "searching": true,
      "language": {
            "url": "<?=base_url('media/assets/global/plugins/datatables/media/js')?>/indonesian.json"
       },
      "columnDefs": [
        {"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>


<script>
  $(document).ready(function () {
    $('.datepickers').datepicker({
      format: 'dd-mm-yyyy' 
    });
  });
</script>
