<?php include("../Header/Session.php"); ?>
<?php include("../Header/Connection.php"); ?>

<?php
if ($ref_code != "MGP10000") 
{
    echo "<script type='text/javascript'>alert('You are not authorized');</script>";
    unset($_SESSION['sess_user']);
    session_destroy();
    echo "<script type='text/javascript'> document.location='https://mygoldsdnbhd.com/log-masuk/'; </script>";
} 
?>

<!DOCTYPE html>
<html lang="en">
<?php include ("../Header/head.php"); ?>
<body class="skin-default fixed-layout">
    <div id="main-wrapper">    
        <?php include ("../Header/header.php"); ?>
        <?php include ("../Header/left_menu.php"); ?>
        <?php include ("../Header/right_sidebar.php"); ?>
        <div class="page-wrapper">
            <div class="container-fluid">
                <br><br>
                <?php
                $q_rules = "SELECT *
                            FROM system_setting
                            Where status='1'";
                $result_rules = $mysqli->query($q_rules);
	            if ($result_rules ->num_rows > 0)
	            {
		            $row_q_rules = $result_rules ->fetch_assoc();
		            $id = $row_q_rules['id'];
                    $withdraw_button = $row_q_rules['withdraw_button'];
                    $withdraw_profit_button = $row_q_rules['withdraw_profit_button'];
                    $withdraw_fees = $row_q_rules['withdraw_fees'];
                    $tac_enablation_button = $row_q_rules['tac_enablation_button'];
                    $purchase_package_status = $row_q_rules['purchase_package_status'];
                    $login_status = $row_q_rules['login_status'];
                    $e_wallet_transfer = $row_q_rules['e_wallet_transfer'];
                    $a_wallet_transfer = $row_q_rules['a_wallet_transfer'];
                    $bonus_sponsor = $row_q_rules['bonus_sponsor'];
                    $registration_fee = $row_q_rules['registration_fee'];
                    $registration_payment_status = $row_q_rules['registration_payment_status'] ?? '1';
	            }

                if ($withdraw_button == '1') { $withdraw_button_check = "checked"; } else { $withdraw_button_check = ""; }

                if ($withdraw_profit_button == '1') { $withdraw_profit_button_check = "checked"; } else { $withdraw_profit_button_check = ""; }

                if ($tac_enablation_button == '1') { $tac_enablation_button_check = "checked"; } else { $tac_enablation_button_check = ""; }

                if ($purchase_package_status == '1') { $purchase_package_status_check = "checked"; } else { $purchase_package_status_check = ""; }

                if ($login_status == '1') { $login_status_check = "checked"; } else { $login_status_check = ""; }

                if ($e_wallet_transfer == '1') { $e_wallet_transfer_check = "checked"; } else { $e_wallet_transfer_check = ""; }

                if ($a_wallet_transfer == '1') { $a_wallet_transfer_check = "checked"; } else { $a_wallet_transfer_check = ""; }

                if ($registration_payment_status == '1') { $registration_payment_status_check = "checked"; } else { $registration_payment_status_check = ""; }
                ?>
                
                <div class="row">
                <div class="col-lg-12">
                <div class="card">
                    <div class="card-body">
                    <form id="postForm" method="post" action="../Controller/Database_sql.php" enctype="multipart/form-data" onsubmit="return confirm('Do you want to proceed?');" onsubmit="return postForm()">
                    <div class="form-body">
                            <h3 class="card-title">System Setting</h3>
                            <hr>
                    </div>  
                    <div class="row p-t-20">
                        <div class="col-md-6">
                            <div class="form-group">
                                <input type="checkbox" name="withdraw_button" value="1" <?php echo $withdraw_button_check;?>>
                                <label> Withdraw E-Wallet Permission</label><br><br> 

                                <input type="checkbox" name="tac_enablation_button" value="1" <?php echo $tac_enablation_button_check;?>>
                                <label> TAC No Permission</label><br><br>

                                <input type="checkbox" name="login_status" value="1" <?php echo $login_status_check;?>>
                                <label> Login Permission</label><br><br>

                                <input type="checkbox" name="registration_payment_status" value="1" <?php echo $registration_payment_status_check;?>>
                                <label> New User Registration Need To Pay</label><br><br>

                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <input type="hidden" class="form-control" name="id" value="<?php echo $id; ?>">
                        <button name="Update_System_Setting" class="btn btn-primary"><i class="fa fa-check"></i> Update</button>
                    </div>
                    <br>
                    </form>
                </div>
                </div>
                </div>
                </div>

                <!--div class="row">
                <div class="col-lg-12">
                <div class="card">
                    <div class="card-body">
                    <form id="postForm" method="post" action="../Controller/Database_sql.php" enctype="multipart/form-data" onsubmit="return confirm('Do you want to proceed?');" onsubmit="return postForm()">
                    <div class="form-body">
                        <h3 class="card-title"> Bonus Sponsor (%)</h3>
                        <hr>
                    </div>  
                    <div class="row p-t-20">
                        <div class="col-md-6">
                            <div class="form-group">
                                <input type="number" class="form-control" name="bonus_sponsor" value="<?php echo $bonus_sponsor;?>">
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <input type="hidden" class="form-control" name="id" value="<?php echo $id; ?>">
                        <button name="Update_Bonus_Sponsor" class="btn btn-primary"><i class="fa fa-check"></i> Update</button>
                    </div>
                    </div>
                    </form>
                </div-->

                <div class="card">
                    <div class="card-body">
                    <form id="postForm" method="post" action="../Controller/Database_sql.php" enctype="multipart/form-data" onsubmit="return confirm('Do you want to proceed?');" onsubmit="return postForm()">
                    <div class="form-body">
                        <h3 class="card-title"> Withdraw Fees Setting (%)</h3>
                        <hr>
                    </div>  
                    <div class="row p-t-20">
                        <div class="col-md-6">
                            <div class="form-group">
                                <input type="number" step="0.01" class="form-control" name="withdraw_fees" value="<?php echo $withdraw_fees;?>">
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <input type="hidden" class="form-control" name="id" value="<?php echo $id; ?>">
                        <button name="Update_Withdraw_Fees" class="btn btn-primary"><i class="fa fa-check"></i> Update</button>
                    </div>
                    </div>
                    </form>
                </div>

                <div class="card">
                    <div class="card-body">
                    <form id="postForm" method="post" action="../Controller/Database_sql.php" enctype="multipart/form-data" onsubmit="return confirm('Do you want to proceed?');" onsubmit="return postForm()">
                    <div class="form-body">
                        <h3 class="card-title"> Registration Fee (RM)</h3>
                        <hr>
                    </div>  
                    <div class="row p-t-20">
                        <div class="col-md-6">
                            <div class="form-group">
                                <input type="number" step="0.01" class="form-control" name="registration_fee" value="<?php echo $registration_fee;?>">
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <input type="hidden" class="form-control" name="id" value="<?php echo $id; ?>">
                        <button name="Update_Registration_Fee" class="btn btn-primary"><i class="fa fa-check"></i> Update</button>
                    </div>
                    </div>
                    </form>
                </div>

                </div>
                </div>
                </div>



            </div>
        </div>
        <?php include ("../Footer/footer.php"); ?>
    </div>
    <?php include ("../Header/all_jquery.php"); ?>

</body>

</html>
