<?php
require_once '../../../config.php';
$check_provider = $db->query("SELECT * FROM provider ORDER BY id DESC");

$id = $_GET['id'];
if(!isset($id))
    die('No direct script access allowed!');
$query = mysqli_query($db, "SELECT * FROM layanan_pulsa WHERE id = '$id'");
$q = mysqli_fetch_assoc($query); 
$check_img = $db->query("SELECT * FRoM gambar_produk ORDER BY id DESC");
?>

<form method="POST">
<div class="form-group mb-3">
        <label>ID</label>
        <input type="text" class="form-control" name="pid" value="<?= $q['id']; ?>" readonly>
    </div>
<div class="form-group mb-3">
        <label>Layanan</label>
        <input type="text" class="form-control" name="layanan" value="<?= $q['layanan']; ?>">
    </div>
    <div class="form-group mb-3">
        <label>Gambar Produk</label>
        <select class="form-control" name="gambar" value="<?= $q['img'];?>">
				<option value="0">- Pilih Gambar Produk -</option>
				<?php while($fetch = $check_img->fetch_assoc()){?>
					<option value="<?= $fetch['img'];?>" <? $fetch['img'] == $q['img'] ? 'selected' : '';?>><?= $fetch['nama_gambar'];?></option>
				<?php };?>
			</select>
			<small class="text-danger">*Now: <?= $q['img']; ?></small>
    </div>
<div class="form-group mb-3">
        <label>Note</label>
        <input type="text" class="form-control" name="note" value="<?= $q['note']; ?>">
    </div>
    <div class="form-group mb-3">
        <label>Harga Basic</label>
        <input type="text" class="form-control" value="<?= $q['harga'] - $q['profit']; ?>" name="harga">
    </div>
    <div class="form-group mb-3">
        <label>Harga Reseller</label>
        <input type="text" class="form-control" value="<?= $q['harga_reseller'] - $q['profit']; ?>" name="harga_ress">
    </div>
    <div class="form-group mb-3">
        <label>Harga Reseller Premium</label>
        <input type="text" class="form-control" value="<?= $q['harga_premium'] - $q['profit']; ?>" name="harga_prem">
    </div>
    <div class="form-group mb-3">
        <label>Type</label>
        <select class="form-control" name="tipe">
				<option value="0">- Select One -</option>
				
					<option value="VGAME" <?= $q['tipe'] == 'VGAME' ? 'selected' : '' ?>>Voucher Game</option>
					<option value="PULSA" <?= $q['tipe'] == 'PULSA' ? 'selected' : '' ?>>Pulsa</option>
					<option value="DATA" <?= $q['tipe'] == 'DATA' ? 'selected' : '' ?>>Paket Data</option>
					<option value="EMONEY" <?= $q['tipe'] == 'EMONEY' ? 'selected' : '' ?>>E-money</option>
					<option value="SMSDANTELPON" <?= $q['tipe'] == 'SMSDANTELPON' ? 'selected' : '' ?>>Sms & Telpon</option>
			</select>
    </div>
    <div class="form-group mb-3">
        <label>Status</label>
        <select class="form-control" name="status">
            <option value="Normal" <?= $q['status'] == 'Normal' ? 'selected' : '' ?>>Normal</option>
            <option value="Gangguan" <?= $q['status'] == 'Gangguan' ? 'selected' : '' ?>>Gangguan</option>
    </select>
    </div>
      <div class="form-group mb-3">
                <label>Provider</label>
                <select class="form-control" name="provider" >
                    <option value="">- Select One -</option>
                    <option value="DF" <?= $q['provider'] == 'DF' ? 'selected' : ''?>>DigiFlazz</option>
                    <option value="AG" <?= $q['provider'] == 'AG' ? 'selected' : ''?>>ApiGames</option>
                    <option value="VR" <?= $q['provider'] == 'VR' ? 'selected' : ''?>>VipReseller</option>
                    <option value="MP" <?= $q['provider'] == 'MP' ? 'selected' : ''?>>MedanPedia</option>
                    <option value="SO" <?= $q['provider'] == 'SO' ? 'selected' : ''?>>SmileOne</option>
                    <option value="Manual" <?= $q['provider'] == 'Manual' ? 'selected' : ''?>>Manual</option>
                </select>
            </div>
    <hr>
    <div class="float-right">
                <button type="button" data-bs-dismiss="modal" aria-label="Close" class="btn btn-block bg-light fw-bold">BACK</button>
                <button type="submit" name="edit_layanan" class="btn btn-block text-white bg-primary fw-bold">CHANGE</button>
            </div>
</form>
