<!DOCTYPE html>
<html lang="en">
<?php
include('include/head.php');
include("loginCheck.php");
include('include/header.php');
include('include/menu.php');
?>
<div id="main-content">
    <div class="container-fluid">
        <div class="block-header">
            <div class="row">
                <div class="col-lg-5 col-md-8 col-sm-12">
                    <h2>
                        <a href="javascript:void(0);" onclick="window.history.back();" class="btn btn-xs btn-link btn-toggle-fullwidth">
                            <i class="fa fa-arrow-left"></i>
                        </a>Farming Percent Update
                    </h2>
                    <ul class="breadcrumb">
                        <li class="breadcrumb-item"><a href="dashboard"><i class="icon-home"></i></a></li>
                        <li class="breadcrumb-item">Setting</li>
                        <li class="breadcrumb-item active">Farming Percent Update</li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="row clearfix">
            <div class="col-lg-12 col-md-12 col-sm-12">
                <div class="card">
                    <div class="header">
                        <h2>Farming Percent Update</h2>
                    </div>
                    <div class="body">
                        <div class="table-responsive">
                            <table class="table table-hover dataTable table-custom mb-0">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Package</th>
                                        <th>Farming Percent</th>
                                        <th>Action</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    $queryConfig = mysqli_query($con, "SELECT * FROM meddolic_config_package_type");
                                    $i = 1;
                                    while ($valConfig = mysqli_fetch_assoc($queryConfig)) {
                                    ?>
                                        <tr>
                                            <form action="farmingSettingProcess.php" method="POST" class="mb-0">
                                                <td><?= $i ?></td>
                                                <td>Package <?= $valConfig['packageId']?></td>
                                                <td>
                                                    <input type="number" step="0.01" min="0" max="100" name="roiPercent" class="form-control"
                                                        value="<?= htmlspecialchars($valConfig['roiPercent']) ?>" required>
                                                    <input type="hidden" name="packageId" value="<?= $valConfig['packageId']?>">
                                                </td>
                                                <td class="text-center">
                                                    <input type="submit" class="btn btn-success" name="updateFarming" value="Update">
                                                </td>
                                            </form>
                                        </tr>
                                    <?php $i++;
                                    } ?>
                                </tbody>
                            </table>
                            <?php if (isset($_GET['status']) && $_GET['status'] == 'success') { ?>
                                <div class="alert alert-success mt-3">Farming percent updated successfully.</div>
                            <?php } ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php include('include/footer.php'); ?>

<script>
    var d = document.getElementById("Setting");
    if (d) d.className += " active";
    var d2 = document.getElementById("farmingSetting");
    if (d2) d2.className += " active";
</script>
</body>

</html>