<?php require_once('../auth/auth.php'); ?>
<div class="row">
  <div class="col-md-3 pr-0">
  <div class="card card-primary card-outline direct-chat direct-chat-primary shadow-none" style="border-left:1px solid #969c9d;border-right:1px solid #969c9d;border-bottom:1px solid #969c9d;">
        <div class="card-header" style="padding: 3px 8px;">
          <h3 class="card-title"><?php echo language(215);?></h3>
          <div class="card-tools m-0">
            <button type="button" class="btn btn-tool" data-card-widget="remove">
              <i class="fas fa-times"></i>
            </button>
          </div>
        </div>    
        <div class="card-header" style="padding: 3px 8px;">
         <div class="input-group input-group-sm float-left" style="width:220px;">
            <input type="text" name="table_search" class="form-control search" placeholder="Search">
         </div>
          <div class="card-tools m-0">
      <div class="btn-group">
        <button type="button" class="btn btn-success p-1" onclick="pagecall('../sms/single_sms.php','#sms_sview');"><i style="font-size:16px" class="p-0 fas fa-sms"></i></button>
    
      </div>
          </div>
        </div>
             <div class="card-body table-responsive p-0 cscroll" style="max-height: 400px;">
            <table class="table table-sm table-head-fixed " style="overflow-x: auto;margin-bottom:0px !important;text-shadow: 0 0 black !important;">
                   <thead>
                      <tr>
                         <th class="text-center" style="width:15%;" ><?php echo language(15)?></th>
                         <th class="text-left" style="width:85%;"><?php echo language(215)?></th>
                      </tr>
                   </thead>
          <?php 
            $ac_tquery= mysqli_query($conn,"SELECT acid,ac_name,ac_number,balance FROM accounts WHERE coid='$coid' AND bid='$bid' AND active=1 ORDER BY acid DESC") or die (mysqli_error($conn));
              $data = [];
              while ($acid= mysqli_fetch_assoc($ac_tquery)){ $data[]=$acid;}
          ?>                   
                   <tbody class="actived" id="sshow"></tbody>
                </table>
             </div> 
       </div> 
  </div>
  <div class="col-md-9" id="sms_sview"></div>
</div>

<script type="text/javascript">
  $(document).ready(function(){
    var acdata = '';
    var i = 0;
    $.each(<?php echo json_encode($data) ?>, function(key,ac){
      acdata += '<tr onclick="itemprofile('+  ac.acid +')">';
      acdata += '<td style="text-align:center;">'+ ++i +'</td>';
      acdata += '<td style="text-align:left;">'+ ac.ac_name +'  '+ ac.ac_number +'</td>';
      acdata += '</tr>';
    });
    $("#sshow").append(acdata);
  });

  function itemprofile(acid){    
    pagecall('../sms/single_sms_lite.php?acid='+acid,'#sms_sview'); 
  }  
</script>

<script>
$(document).ready(function(){
  $('.search').on('keyup',function(){
    var searchTerm = $(this).val().toLowerCase();
    $('.actived tr').each(function(){
      var lineStr = $(this).text().toLowerCase();
      if(lineStr.indexOf(searchTerm) === -1){
        $(this).hide();
      }else{
        $(this).show();
      }
    });
  });
});
</script>


