<?php
$stmt = $pdo->prepare("SELECT 
    SUM(user_hs_aktif) AS user_hs_aktif
    FROM v_jumlah_pelanggan $SqlDataWHIdM");
  $stmt->execute();
  $datauser = $stmt->fetchAll();
?>
<!-- Main content -->
<section class="content" style="zoom : 88%;">
  <div class="container-fluid">
    <div class="row">
      <div class="col-12">
        <div class="card">
          <div class="card-header">
            <div class="row">
              <div class="col-sm-6">
                <h4>Pelanggan Register</h4>
              </div>
              <div class="col-sm-6">
                <ol class="float-sm-right mb-0">
                <?php if(in_array("Tambah", $json_array[2]['sub_menu'])){ ?>
                <a href="?<?php echo encrypt_url('user_tambah');?>" class="btn btn-danger btn-sm">Tambah</a></ol>
                <?php } ?>
              </div>
            </div>
          </div>
          <!-- /.card-header -->
          <div class="card-body">
            <table id="example1" class="table table-bordered table-striped">
              <thead>
              <tr class="bg-secondary">
                <th style="max-width: 20px">No</th>
                <th>Id Pelanggan</th>
                <?php if($datauser[0]['user_hs_aktif'] > 0) { ?>
                <th>Akun Hotspot</th>
                <?php } ?>
                <th>Nama</th>
                <th>Alamat</th>
                <th>Koordinat</th>
                <th>Nomor WhatsApp</th>
                <th>Server</th>
                <th>Paket</th>
                <th>Topologi</th>
                <th>Action</th>
              </tr>
              </thead>
              <tbody>
            <?php
            $no = 1;
            $aserver = mysqli_query($con,"SELECT id,akun,user_hotspot,nama,alamat,latitude,longitude,nomor_whatsapp,nama_server,nama_paket,nama_topologi,port_odp FROM v_pelanggan WHERE $SqlSvData status = 'register'");
            while ($server = mysqli_fetch_assoc($aserver)) 
            {
            ?>
              <tr>
                <td style="max-width: 20px"><?php echo $no; ?></td>
                <td><?php echo $server['akun']; ?></td>
                <?php if($datauser[0]['user_hs_aktif'] > 0) { ?>
                <td><?php echo $server['user_hotspot']; ?></td>
                <?php } ?>
                <td><?php echo $server['nama']; ?></td>
                <td style="max-width: 200px"><?php echo $server['alamat']; ?></td>
                <td><a href="https://google.com/maps/?q=<?php echo $server['latitude'].','.$server['longitude']; ?>" target="_blank"><?php echo $server['latitude'].', '.$server['longitude']; ?></a></td>
                <td>
                  <?php echo $server['nomor_whatsapp'];?>
                   <a href="https://wa.me/<?php echo $server['nomor_whatsapp']; ?>" target="_blank" style="border-radius: 20px;" class="btn btn-sm btn-success"><i class="fab fa-whatsapp"></i></a>   
                </td>
                <td><?php echo $server['nama_server']; ?></td>
                <td><?php echo $server['nama_paket']; ?></td>
                <td style="max-width: 100px"><?php echo $server['nama_topologi'].' Port '.$server['port_odp']; ?></td>
                <td>
                  <a href="?<?php echo encrypt_url('user_detail|'.$server['id'].'|'.$page[0]); ?>" class="btn btn-sm btn-warning btn-sm m-1">Aktivasi / Edit</a>
                </td>
              </tr>
              
            <?php $no++; } ?>
              </tbody>
            </table>
          </div>
          <!-- /.card-body -->
        </div>
        <!-- /.card -->
      </div>
      <!-- /.col -->
    </div>
    <!-- /.row -->
  </div>
  <!-- /.container-fluid -->
</section>