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

<!DOCTYPE html>
<html lang="en">
<?php include ("../Header/head.php"); ?>
<body class="skin-default fixed-layout">

<!-- Main wrapper - style you can find in pages.scss -->
<div id="main-wrapper">    
<?php include ("../Header/header.php"); ?>
<?php include ("../Header/left_menu.php"); ?>
<?php include ("../Header/right_sidebar.php"); ?>
        
<!-- Page wrapper  -->
<div class="page-wrapper">
<!-- Container fluid  -->
<div class="container-fluid">
<!-- Bread crumb and right sidebar toggle -->
<!--?php include ("../Header/breadcumb.php"); ?-->
<br><br>
<!-- End Bread crumb and right sidebar toggle -->
<!-- Start Page Content -->
<!-- ============================================================== -->

<?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>";
} 
?>

<?php
$package_ref_code = $_GET['package_ref_code'];

$sql = "SELECT * 
FROM package_setting
WHERE package_ref_code ='$package_ref_code'
And status='1'";
$result = $mysqli->query($sql);
if ($result->num_rows > 0)
{
	$row = $result ->fetch_assoc();
	$package_name = $row['package_name'];
    $package_price = $row['package_price'];
}
?>

<!--div class="row">
<div class="col-lg-12">
<div class="card">
    <div class="card-body">
        <form method="post" action="../Controller/Database_sql.php" enctype="multipart/form-data">
            <div class="form-body">
                <h3 class="card-title">Add New Package Setting</h3>
                <hr>
                <div class="row p-t-20">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label">Package Name</label>
                            <input type="text" class="form-control" name="package_name" required>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label">Package Price (RM)</label>
                            <input type="number" class="form-control" name="package_price" required>
                        </div>
                    </div>                      
                </div>
            </div>
            <div class="form-actions">
                <button name="Add_Package_Setting" class="btn btn-success"><i class="fa fa-check"></i> Add</button>
            </div>
        </form>
    </div>
</div>
</div>
</div-->

<div class="row">
<div class="col-12">
<div class="card">
    <div class="card-body">
        <h4 class="card-title">Commission Settings For <?php echo $package_name; ?> | RM <?php echo $package_price; ?></h4>
        <div class="table-responsive m-t-40">            
            <table class="display nowrap table table-hover table-striped table-bordered" cellspacing="0" width="100%">
                <thead>
                    <tr>
                         <th>Level 1 PACKAGE VIP(RM)</th>
                         <th>Level 1 PACKAGE OTHER THAN VIP (RM)</th>
                         <th>Level 2 (RM)</th>
                         <th>Level 3 (RM)</th>
                         <th>Level 4 (RM)</th>
                         <th>Level 5 (RM)</th>
                        <th>Action</th>
                    </tr>
                </thead>                                      
                <tbody>
                    <?php
                    $q = "SELECT *
                    FROM commission_setting
                    Where package_ref_code = '$package_ref_code'
                    And status='1'
                    order by id Asc";
                    $result = $mysqli->query($q);
                    if ($result ->num_rows > 0)
                    {
                        while($record = $result -> fetch_assoc())
                        {    
						    $id = $record['id'];
                            $package_ref_code = $record['package_ref_code'];
                            $level_1 = $record['level_1'];
                            $level_1_1 = $record['level_1_1'];
                            $level_2 = $record['level_2']; 
                            $level_3 = $record['level_3']; 
                            $level_4 = $record['level_4']; 
                            $level_5 = $record['level_5']; 
                    ?>
                    <form method="post" onsubmit="return confirm('Do you want to proceed?');" action="../Controller/Database_sql.php" enctype="multipart/form-data">
                    <tr>
                        <td><input type="number" step="0.01" class="form-control" name="level_1" value="<?php echo $level_1; ?>"></td>   
                        <td><input type="number" step="0.01" class="form-control" name="level_1_1" value="<?php echo $level_1_1; ?>"></td>   
                        <td><input type="number" step="0.01" class="form-control" name="level_2" value="<?php echo $level_2; ?>"></td>   
                        <td><input type="number" step="0.01" class="form-control" name="level_3" value="<?php echo $level_3 ?>"></td>   
                        <td><input type="number" step="0.01" class="form-control" name="level_4" value="<?php echo $level_4; ?>"></td>   
                        <td><input type="number" step="0.01" class="form-control" name="level_5" value="<?php echo $level_5; ?>"></td>  
                        <input type="hidden" class="form-control"  name="id" value="<?php echo $id; ?>">
                        <input type="hidden" class="form-control"  name="package_ref_code" value="<?php echo $package_ref_code; ?>">
                        <td>
                            <button name="Update_Commission_Setting" class="btn btn-success"><i class="fa fa-check"></i> Update</button>                                  
                        </td>
                    </form> 
                    </tr>
                    <?php 
                    }
                    }
                    ?>
                </tbody>
            </table>
            </form>  
            <a href="package_setting_1.php" class="btn btn-success">Back</a>
        </div>
    </div>
</div>                      
</div>
</div>
<!-- ============================================================== -->
<!-- End PAge Content -->

</div>
<!-- End Container fluid  -->
</div>
<!-- End Page wrapper  -->

<!-- Footer Start-->
<?php include ("../Footer/footer.php"); ?>
<!-- Footer End-->

</div>
<!-- End Wrapper -->
<!-- All Jquery -->
    

<!-- All Jquery Start-->
<?php include ("../Header/all_jquery.php"); ?>
<!-- All Jquery End-->

</body>

</html>