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

<?php
$comm_id = $_GET['comm_id'];
?>

<!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 -->
<!-- ============================================================== -->
<div class="row">
<div class="col-12">
    <div class="card">
        <div class="card-body">
            <h4 class="card-title">Edit COM00<?php echo $comm_id;?></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>Action</th>
                            <th>Commission ID</th>                           
                            <th>Agent Detail</th>
                            <th>Description</th>
                            <th>Commission Amount</th>
                            <th>Wallet Balance</th>
						    <th>Date<font color="white">____________</font></th>
                        </tr>
                    </thead>                                      
                    <tbody>
                        <?php
                        $q = "SELECT *
                        FROM transactions
                        Where id = '$comm_id' ";
                        $result = $mysqli-> query($q);
                        if ($result -> num_rows > 0)
                        {
	                        while($record = $result -> fetch_assoc())
	                        {

                            $id = $record['id'];
                            $user_ref_code = $record['user_ref_code'];
                            $in_transactions = number_format($record['in_transactions'],2);
						    $balance = number_format($record['balance'],2);
                            $description = $record['description'];
                            $created_date = $record['created_date'];
                            //$created_date = date('d-m-Y', strtotime($created_date));
						    $status = $record['status'];

                            $sql_user = "SELECT * FROM user 
                            WHERE ref_code='$user_ref_code'
                            And status='1'";
                            $result_user = $mysqli-> query($sql_user);
	                        if ($result_user -> num_rows > 0)
	                        {
		                        $row_user = $result_user ->fetch_assoc();
		                        $level = $row_user['level'];
                                $type_of_user = $row_user['type_of_user'];
                                $name = $row_user['name'];
                                $last_name = $row_user['last_name'];
                                $email = $row_user['email'];
                                $phone_number = $row_user['phone_number'];  
	                        }
                        ?>
                        <form method="post" action="../Controller/Database_sql.php" enctype="multipart/form-data">
                        <tr>
                            <td><button name="update_transaction" class="btn btn-primary"><i class="fa fa-check"></i> Update</button></td>
                            <td>COM00<?php echo $id;?></td>
                            <td><?php echo $user_ref_code;?> | <?php echo $name;?> | <?php echo $type_of_user;?>   </td>
							<td><?php echo $description;?></td>
                            <td>$<input type="text" class="form-control" name="in_transactions" value="<?php echo $in_transactions; ?>"></td>
                            <td>$<input type="text" class="form-control" name="balance" value="<?php echo $balance; ?>"></td>
                            <td><input type="text" class="form-control" name="created_date" value="<?php echo $created_date; ?>"></td>
                            <input type="hidden" class="form-control" name="comm_id" value="<?php echo $comm_id; ?>">
                        </tr>
                        </form>
                        <?php 
                            }
                        }
                        ?>
                    </tbody>
                    </table>                        
            </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>