<?php
	session_start();
	if($_SESSION['did'])
	{
		$userid= $_SESSION['did'];
	}
	else
	{
		header('location:../login.php');
	}
?>
<html>
<head>
<style>

</style>
</head>
<body>
<?php
    include'connection.php';
    $uid=$_GET['uid'];
    $quGetName="select * from retailer where Userid='$uid'";
    $reGetName=mysqli_query($con,$quGetName);
    $dataGetName=mysqli_fetch_array($reGetName);
    $retName=$dataGetName['Name'];
    
    $sl=0;
        $quGetColumnName="select * from operator";
        $reGetColumnName=mysqli_query($con,$quGetColumnName);
        
    
            echo "<table border='1' cellpadding='10'>";
                echo "<tr>";
                    echo "<th>Sl. No.</th>";
                    echo "<th>Operator</th>";
                    echo "<th>Commission</th>";
                echo "</tr>";
        while($dataGetColumnName=mysqli_fetch_array($reGetColumnName))
        {
        
            $ColumnName=$dataGetColumnName['Commision_Column'];
            $OpName=$dataGetColumnName['Operator'];
            $CommissionValue=$dataGetColumnName['RetComm'];
            $sl=$sl+1;
                echo "<tr>";
                    echo "<td>".$sl."</td>";
                    echo "<td>".$OpName."</td>";
                    echo "<td>".$CommissionValue."</td>";
                echo "</tr>";
            
           // $quResetComm="update commision set $ColumnName='$CommissionValue' where Userid='$uid'";
            //mysqli_query($con,$quResetComm);
        }
    
        echo "</table>";
    
    if(isset($_POST['submit']))
    {
        $quGetColumnName="select * from operator";
        $reGetColumnName=mysqli_query($con,$quGetColumnName);
        
        while($dataGetColumnName=mysqli_fetch_array($reGetColumnName))
        {
        
            $ColumnName=$dataGetColumnName['Commision_Column'];
            $OpName=$dataGetColumnName['Operator'];
            $CommissionValue=$dataGetColumnName['RetComm'];
            
            $quResetComm="update commision set $ColumnName='$CommissionValue' where Userid='$uid'";
            mysqli_query($con,$quResetComm);
        }
        echo "<center><h3 style='color:green;'>Commission Reset By Default Successfully!</h3></center><br><br>";
        echo "<center><a href='set_commission.php?id=".$uid."'>Back</a></center>";
    }
?>
<h3>Click SUBMIT If You Want To Reset Commission By Default For...<?php echo $retName."[".$uid."]"; ?></h3><br>
<form method="post">
<input type="submit" name="submit">
</form>
</body>
</html>