<?php
require_once '../config.php';

//error_reporting(0);
if($_GET['id']){
    $explode = explode('_',$_GET['id']);
    $produkID = $explode[0];
    $brand = $explode[1];
    $kabupaten = mysqli_query($conn,"SELECT * FROM `layanan_pulsa` WHERE tipe = '$produkID' AND operator = '$brand' AND status = Normal ORDER BY harga_jual ASC") or die(mysqli_error($conn));
    $no=0;
    while($kk = mysqli_fetch_array($kabupaten)){
        $no++;
        if(isset($_SESSION['user'])){
            $usernya = $_SESSION['user'];
            $cekUser = mysqli_query($conn,"SELECT * FROM `users` WHERE username = '$user_guest'");
            $cu = mysqli_fetch_array($cekUser);
            if($cu['level'] == 'Reseller'){
              $harga = $kk['harga_reseller'];
            }
            else {
              $harga = $kk['harga'];
            }
        }  
        else {
            $harga = $kk['harga'];
        }
                          
?>
                      <div class="col-sm-4 col-6">
                        <input required="" type="radio" id="layanan_<?php echo $no; ?>" class="radio-nominale" name="produkID" value="<?php echo $kk['cuid']; ?>">
                        <label for="layanan_<?php echo $no; ?>">
                          <?php echo $kk['title']; ?><br>
                          <small>Rp. <?php echo number_format($harga); ?></small>
                        </label>
                      </div>          
                  
<?php
}
}
?>
<script>
      $(document).ready(function() {
        $("input:radio[name=produk]").change(function (){
            url = "<?= base_url(); ?>id/ajax/select_pulsa.php?id="+$('input:radio[name=produk]:checked').val();
            $('#accordionExample').load(url);
            //console.log(url);
            return false;
        });
      });
  </script>