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

	$post_kategori = $_POST['operator'];
	$cek_layanan = $db->query("SELECT * FROM layanan_pulsa WHERE operator = '$post_kategori' AND tipe!='SOSMED' ORDER BY harga ASC");
	if (mysqli_num_rows($cek_layanan) !== 0) {
	?>
                     <div class="table-responsive">
                                    <table class="table table-striped table-dark table-bordered table-hover" id="tbb">
                                        <thead>
                                            <tr>
                                                <th>Code Produk</th>
                                                <th>Layanan</th>
                                                <th>Basic</th>
                                                <th>Reseller</th>
                                                <th>Vip</th>
                                                <th>Status</th>
                                            </tr>
                                        </thead>
                            <tbody>
                            <?php
                            while ($data_layanan = mysqli_fetch_assoc($cek_layanan)) {
                            if($data_layanan['status'] == "Normal") {
                                $label = "success";
                                $icon = "mdi mdi-checkbox-marked-circle-outline";
                            } else if($data_layanan['status'] == "Gangguan") {
                                $label = "danger";
                                $icon = "mdi mdi-close-circle-outline";
                            }
                            ?>
                                <tr class="text-center">
                                    <td><?= $data_layanan['service_id']; ?></td>
                                    <td><?= $data_layanan['layanan']; ?></td>
                                    <td>Rp <?= number_format($data_layanan['harga'],0,',','.'); ?></td>
                                    <td> Rp <?= number_format($data_layanan['harga_reseller'],0,',','.'); ?></td>
                                    <td>Rp <?= number_format($data_layanan['harga_premium'],0,',','.'); ?></td>                                    
                                    <td><span class="text-<?= $label; ?>"><i class="<?= $icon; ?>"></i> <?= $data_layanan['status']; ?></span></td>                                    
                                </tr>
                                <?php } ?>
                            </tbody>
                        </table>
                    </div>
<?php
} else {
?>
                     <div class="table-responsive">
                                    <table class="table table-striped table-dark table-bordered table-hover" id="tbb">
                                        <thead>
                                            <tr>
                                                <th>Code Produk</th>
                                                <th>Nama Games</th>
                                                <th >Layanan</th>
                                                <th >Basic</th>
                                                <th>Reseller</th>
                                                <th >VIP</th>
                                                <th>Status </th>
                                            </tr>
                                        </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
<?php
}