<?php require_once('../auth/auth.php'); ?>
<?php
    $company_query= mysqli_query($conn,"SELECT co_name,owner_name,co_phone,co_email,co_address,co_logo,a.ac_name FROM accounts a LEFT JOIN company c ON(a.coid=c.coid) WHERE a.coid='$coid'  ") or die (mysql_error());
    $inac= mysqli_fetch_assoc($company_query);
    $ac_name        = $inac['ac_name'];
    $co_name        = $inac['co_name'];
    $owner_name     = $inac['owner_name'];
    $co_address     = $inac['co_address'];
    $co_phone       = $inac['co_phone'];
    $co_email       = $inac['co_email'];
    $co_logo        = $inac['co_logo'];	
?>
<section class="content">
   <div class="container-fluid">
      <div class="row">
        <div class="col-md-12">
          <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">Login History</h3>
                <div class="card-tools"><span id="sdf"></span>
                  <button type="button" class="btn btn-tool" data-card-widget="remove"><i class="fas fa-times"></i></button>
                </div>
            </div>    	
            <div class="card-body p-1">
        
    </tr>
                <table id="trbl_table" class="ttable" cellpadding="0" cellspacing="0">
                  <thead>
                    <tr>                  	
                        <th rowspan="3" colspan="10">
                         <div style="width:12%;float:left;">
                            <img class="profile-user-img img-fluid img-circle" src="../../dist/img/a.png" style="width:80px;height:77px;">
                        </div>
                        <div style="padding-left:2px;float:left;">
                         <sss style="font-size:18px;font-weight: 600;"><?php echo $co_name;?></sss><br>
                         <sss><?php echo $owner_name;?></sss><br>
                         <sss><?php echo $co_address;?></sss><br>
                         <sss><?php echo $co_phone;?></sss> # 
                         <sss><?php echo $co_email;?></sss>
                        </div>
                        </th> 
                        <th colspan="5" class="text-center" style="font-size:13px;">All Branch</th>
                    </tr> 
                    <tr>                   	
                       <th colspan="5" class="text-center" style="font-size:13px;">History List  </th> 
                    </tr>
                    <tr>                   	
                       <th colspan="5" class="text-center" style="font-size:13px;">    <input type="text" id="search" class="form-control form-control-sm search"  
        placeholder="searching" required="true" style="border-radius: ;border:1px solid primary;width:100%; text-align:center; padding:; "> </th>
                    </tr>    
                    
                               
   

                    <tr class="sticky-top">
         
                        <th class="text-center" style="width:3%;">S/l</th>
                        <th style="width:15%;">Company  </th>
                        <th class="text-center" style="width:5%;">intime </th>
                        <th class="text-center" style="width:7%;">ipaddress</th>
                        <th class="text-center" style="width:7%;">browser</th>
                        <th class="text-center" style="width:7%;">opareting</th>

                        <th class="text-center" style="width:5%;">country </th>
                        <th class="text-center" style="width:5%;">city</th>
                        <th class="text-center" style="width:5%;">Zone</th>

                        <th class="text-center" style="width:8%;">lat</th>
                        <th class="text-center" style="width:7%;">longat</th>

                        <th class="text-center" style="width:5%;">symble </th>
                        <th class="text-center" style="width:5%;">currency</th>
                        <th class="text-center" style="width:10%;">urltoken</th>
                        <th class="text-center" style="width:10%;">date</th>
                    </tr>



                </thead>
      <tbody id="colview" class="searchtable">
                    <?php
                        $history_query= mysqli_query($conn,"SELECT * FROM log_data WHERE coid='$coid' ") or die (mysql_error());
                        $i=0;
                        while ($rowac= mysqli_fetch_array ($history_query) ){
                    ?>
                    <tr class="btn-outline-dark" onclick="vprofile('<?php echo $rowac['userid']?>')">
                        <td  style="font-size: 11.5px;width:10%;text-align: center;"><?php echo ++$i ?></td>
                        <td  style="font-size: 11.5px"><?php echo $rowac['username'] ?></td>
                        <td  style="font-size: 11.5px">  <?php echo $rowac['intime']; ?></td>
                        <td  style="font-size: 11.5px"><?php echo $rowac['ipaddress']?></td>
                        <td  style="font-size: 11.5px"> <?php echo $rowac['browser']?></td>
                        <td  style="font-size: 11.5px;width:15%;text-align: center;color:red;"><?php echo $rowac['opareting']?>  </td>
                        <td  style="font-size: 11.5px"> <?php echo $rowac['country']?></td>
                         <td  style="font-size: 11.5px"> <?php echo $rowac['city']?></td>
                          <td  style="font-size: 11.5px"> <?php echo $rowac['earth']?></td>
                            <td  style="font-size: 11.5px"> <?php echo $rowac['lat']?></td>
                            <td  style="font-size: 11.5px"> <?php echo $rowac['longat']?></td>
                            <td  style="font-size: 11.5px"> <?php echo $rowac['symble']?></td>
                            <td  style="font-size: 11.5px"> <?php echo $rowac['currency']?></td>
                            <td  style="font-size: 11.5px"> <?php echo $rowac['urltoken']?></td>
                            <td  style="font-size: 11.5px"> <?php echo $rowac['date']?></td>

                    </tr>
                    <?php } ?>
                </tbody>
    
            </table>
        </div>
    </div>
   </div>
  </div>
</div>
</section>

<script type="text/javascript">
 $(document).ready(function() {
  function vprofile(acid){    
    $("#modal-xl").modal({backdrop: "static"});
    pagecall('../accounts/ac_profile.php?acid='+acid,'#xlmdview');   
}  
toastr.success(Showing, '<?php echo "All Deactive Account View " ?>');

  $('.search').on('keyup',function(){
      var searchTerm = $(this).val().toLowerCase();
      $('.searchtable tr').each(function(){
        var lineStr = $(this).text().toLowerCase();
        if(lineStr.indexOf(searchTerm) === -1){
          $(this).hide();
        }else{
          $(this).show();
        }
      });
    });

    $('th').each(function (col) {
      $(this).hover(
        function () {
          $(this).addClass('focus');
        },
        function () {
          $(this).removeClass('focus');
        }
        );
      $(this).click(function () {
        if ($(this).is('.asc')) {
          $(this).removeClass('asc');
          $(this).addClass('desc selected');
          sortOrder = -1;
        } else {
          $(this).addClass('asc selected');
          $(this).removeClass('desc');
          sortOrder = 1;
        }
        $(this).siblings().removeClass('asc selected');
        $(this).siblings().removeClass('desc selected');
        var arrData = $('table').find('tbody >tr:has(td)').get();
        arrData.sort(function (a, b) {
          var val1 = $(a).children('td').eq(col).text().toUpperCase();
          var val2 = $(b).children('td').eq(col).text().toUpperCase();
          if ($.isNumeric(val1) && $.isNumeric(val2))
            return sortOrder == 1 ? val1 - val2 : val2 - val1;
          else
            return (val1 < val2) ? -sortOrder : (val1 > val2) ? sortOrder : 0;
        });
        $.each(arrData, function (index, row) {
          $('tbody').append(row);
        });
      });
    });
  });
</script>