<?php if($this->session->flashdata('update_sukses_'.$untuk) == true){ ?>
    <div class="alert alert-success">
        <strong>Success!</strong> 
    </div>
<?php }?>
<?php if($this->session->flashdata('update_gagal_'.$untuk) == true){ ?>
    <div class="alert alert-danger">
        <strong>Failed to update data!</strong> 
    </div>
<?php }?>


<div class="portlet-body" id="page-content" style="display:nonee">

    <div class="table-responsive" style="border:0px;">
        <?php 
        if($untuk == 'siak_re_account_chart'){
          $this->db->where('id_tindakan !=','0');
        }

        if($untuk == 'bbmc_tr_amprahan_request'){
          //where id unit
          $jabatan = $this->M_general->get_value('global_jabatan','id_global_jabatan',$this->session->userdata('id_jabatan'), 'nama_jabatan');
          //echo $jabatan;

          if($jabatan == 'Front Office'){
            $this->db->where('id_unit','2');
          }
        }

        $fields = $this->M_general->get_kolom($untuk);
        if(isset($where)){$this->db->where($where);}
        $query = $this->M_general->get_setting($untuk);
        if($query->num_rows() == 0){ ?>
        <div class="" class="form-group" style="margin-bottom:40px; margin-top: 0px; margin-left:0px; padding-bottom: 30px; border-radius:4px; background: linear-gradient(to left, #d14415,#d16b49, #fad2d2 ,transparent,transparent,transparent,transparent)">
          <div class="col-sm-12 col-md-12" style="text-align: right; color: #fff"><h2><strong>No data entry</strong></h2></div><br><br>
        </div>
        <?php }else{ ?>
        <table id="example" class="table table-bordered table-striped table-hover datatable" >
          <thead>

              <tr style="background: #5578eb; color:#fff;">
              <th style="width: 1px; white-space: nowrap;"><i class="fa fa-th-large"></i></th>
              <th class="text-center" style="min-width:30px; width: 30px !important; text-align: center;" style="margin-left: 200px;"><div style="width:100% !important;"><center>NO.</center></div></th>
              <?php 
              $array_in = $this->Content_m->array_in_dinamic();
              $c=0; foreach ($fields as $field) { ?>
                 
                 <?php if($untuk == 'bbmc_re_apotik_obat' && $field == 'harga_jual'){ ?>
                 <th class="text-left" style="width: 50px !important">
                    STOK
                 </th>
                 <th class="text-left" style="width: 150px !important">
                    HARGA BELI TERTINGGI
                 </th>
                 <?php }?>

                 <th class="text-left" style="<?=($c==0 || in_array($field,$array_in))?'display:none;':''?>  width: 1px; white-space: nowrap;">
                    <?php 

                        echo $this->M_general->get_text($field);
                       //echo "string";
                    ?>  
                  </th>
              <?php $c++;}?>
            </tr>
          </thead>
          <tbody>
           <?php 
           $i=1; 
           foreach($query->result_array() as $key) { ?>
                <tr style="font-size:12px; <?=(@$key['active']=='0')?'text-decoration: line-through; opacity:0.4':''?>" >
                <td class="" style="background: #fcf4dc; width: 1px; white-space: nowrap;" align="left">
                      <a class="tooltips btn-xs btn-info" data-toggle="m-tooltip" data-container="body" title="Edit" href="<?=site_url()?>/setting/insert_entry/<?=$untuk?>/update/<?=$key[$fields[0]]?>/" ><i class='fa fa-edit'></i></a>  
                      <?php 
                      if(isset($key['active'])){ 
                          if($key['active'] == '0'){ ?>
                              <a class="tooltips btn-xs btn-danger" data-toggle="m-tooltip" data-container="body" title="Delete" onclick="return confirm('Delete this data?')"  href="<?=site_url()?>/setting/delete_setting/<?=$untuk?>/<?=$key[$fields[0]]?>"><i class='fa fa-times'></i></a>
                          <?php }
                      }
                      ?>
                </td>
                <td align="center"> <?=$i;?> </td>
                <?php $c=0; foreach ($fields as $field) { ?>
                    
                    <?php if($untuk == 'bbmc_re_apotik_obat' && $fields[$c] == 'harga_jual'){ ?>
                    <td class="text-left">
                      <a href="#" target="_Blank" style="color:blue">Loading..</a>
                    </td>
                    <td class="text-left">
                      <a href="#" target="_Blank" style="color:blue">Loading..</a>
                    </td>
                    <?php }?>

                    <td class="text-left" style="<?=($c==0 || in_array($field,$array_in))?'display:none;':''?>  width: 1px; white-space: nowrap;">
                        
                        <?php 
                        echo $this->M_general->get_kolom_value($fields[$c], $key[$field]);
                        ?>

                    </td>
                    
                <?php $c++; }?>
              </tr>
            <?php $i++; }?>
          </tbody>     
        </table>
        <?php }?>

    </div>  
</div>
