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

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

<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 Manager Level</h3>
                <hr>
                <div class="row p-t-20">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label">Name Of Level</label>
                            <input type="text" maxlength="100" class="form-control" name="name_of_level" required placeholder="Pearl">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label">Bonus Percent (%)</label>
                            <input type="number" step="0.01" class="form-control" name="bonus_percent" required value="0.00">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label">Level Remark</label>
                            <input type="text" maxlength="100" class="form-control" name="level_remark">
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-actions">
                <button name="Add_Manager_Level_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">Manager Level Settings</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 Code</th>
                        <th>Name Of Level</th>
                        <th>Bonus Percent (%)</th>
                        <th>Level Remark</th>
                        <th>Action</th>
                    </tr>
                </thead>                                      
                <tbody>
                    <?php
                    $q = "SELECT *
                          FROM `Manager_Level_Setting`
                          WHERE status='1'
                          ORDER BY id DESC";
                    $result = $mysqli->query($q);
                    if ($result ->num_rows > 0)
                    {
                        while($record = $result -> fetch_assoc())
                        {    
                            $id = $record['id'];
                            $manager_level_ref_code = $record['manager_level_ref_code'];
                            $name_of_level = $record['name_of_level'];
                            $bonus_percent = $record['bonus_percent'];
                            $level_remark = $record['level_remark'];
                    ?>
                    <form method="post" onsubmit="return confirm('Do you want to proceed?');" action="../Controller/Database_sql.php" enctype="multipart/form-data">
                    <tr>
                        <td><?php echo $manager_level_ref_code; ?></td>
                        <td><input type="text" maxlength="100" class="form-control" name="name_of_level" value="<?php echo $name_of_level; ?>"></td>
                        <td><input type="number" step="0.01" class="form-control" name="bonus_percent" value="<?php echo $bonus_percent; ?>"></td>
                        <td><textarea maxlength="100" rows="2" class="form-control" name="level_remark"><?php echo $level_remark; ?></textarea></td>
                        <input type="hidden" class="form-control" name="id" value="<?php echo $id; ?>">
                        <td>
                            <button name="Update_Manager_Level_Setting" class="btn btn-success"><i class="fa fa-check"></i> Update</button>
                            <button name="Delete_Manager_Level_Setting" class="btn btn-danger"> Remove</button>                                   
                        </td>
                    </form> 
                    </tr>
                    <?php 
                        }
                    }
                    ?>
                </tbody>
            </table>
            </form>                                 
        </div>
    </div>
</div>                      
</div>
</div>

</div>
</div>

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

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

</body>

</html>
