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

	$post_kategori = $_POST['odper'];
	$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 mb-0">
                                        <thead>
                                            <tr>
                                                <th class="text-center" rowspan="2" style="vertical-align:middle">Code Produk</th>
                                                <th class="text-center" rowspan="2" style="vertical-align:middle" >Layanan</th>
                                                <th class="text-center" colspan="3" style="vertical-align:middle">Harga</th>
                                                <th class="text-center" rowspan="2" style="vertical-align:middle">Status </th>
                                            </tr>
                                            <tr>
                                                <th class="text-center" rowspan="2" style="vertical-align:middle" >Basic</th>
                                                <th class="text-center" rowspan="2" style="vertical-align:middle">Reseller</th>
                                                <th class="text-center" rowspan="2" style="vertical-align:middle" >VIP</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><?php echo $data_layanan['service_id']; ?></td>
                                    <td><?php echo $data_layanan['layanan']; ?></td>
                                    <td>Rp <?php echo number_format($data_layanan['harga'],0,',','.'); ?></td>
                                    <td> Rp <?php echo number_format($data_layanan['harga_reseller'],0,',','.'); ?></td>
                                    <td>Rp <?php echo number_format($data_layanan['harga_premium'],0,',','.'); ?></td>                                    
                                    <td><span class="text-<?php echo $label; ?>"><i class="<?php echo $icon; ?>"></i> <?php echo $data_layanan['status']; ?></span></td>                                    
                                </tr>
                                <?php } ?>
                            </tbody>
                        </table>
                    </div>
<?php
} else {
?>
                     <div class="table-responsive">
                                    <table class="table table-striped zero-configuration mb-0">
                                        <thead>
                                            <tr>
                                                <th class="text-center" rowspan="2" style="vertical-align:middle">Code Produk</th>
                                                <th class="text-center" rowspan="2" style="vertical-align:middle">Nama Games</th>
                                                <th class="text-center" rowspan="2" style="vertical-align:middle" >Layanan</th>
                                                <th class="text-center" colspan="3" style="vertical-align:middle">Harga</th>
                                                <th class="text-center" rowspan="2" style="vertical-align:middle">Status </th>
                                            </tr>
                                            <tr>
                                                <th class="text-center" rowspan="2" style="vertical-align:middle" >Basic</th>
                                                <th class="text-center" rowspan="2" style="vertical-align:middle">Reseller</th>
                                                <th class="text-center" rowspan="2" style="vertical-align:middle" >VIP</th>
                                            </tr>
                                        </thead>
                            <tbody>
                                <tr>
                                    <td colspan="8" class="text-center"><i class="mdi mdi-close-circle-outline"></i> Produk Tidak Ditemukan</td>                                    
                                </tr>
                            </tbody>
                        </table>
                    </div>
<?php
}