<!DOCTYPE html>
<html lang="en" data-bs-theme="dark">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ဝယ်စာရင်း</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha2/dist/css/bootstrap.min.css">
    <script src="https://kit.fontawesome.com/ae360af17e.js" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
    <link rel="stylesheet" href="css/style.css">
    <link rel="icon" href="image/logo.png" type="image/png">

    <link rel="stylesheet" href="extensions/fixed-columns/bootstrap-table-fixed-columns.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <script src="extensions/fixed-columns/bootstrap-table-fixed-columns.js"></script>
</head>
<style>
        .image-container {
            width: 200px; /* Adjust this width as needed */
            height: 200px; /* Adjust this height as needed */
            overflow: hidden;
            position: relative;
            border: 1px solid #ccc; /* Add a border for the frame effect */
        }
        .image-container img {
            width: 100%;
            height: 100%;
            object-fit: contain; /* Ensure the entire image is visible */
        }
    </style>



<?php

session_start();
                                
if (isset($_SESSION['browser_id'])) {
    $browserId = $_SESSION['browser_id'];
} else {
    // Generate a new browser ID
    $browserId = generateUniqueBrowserId();

    // Store the browser ID in the session for future use
    $_SESSION['browser_id'] = $browserId;
}


include "database/database.php";
include "database/data.php";
include "cal_customer_pay.php";
?>


    <style>
    .select-container {
        position: relative;
        display: inline-block;
    }
    .select-container select {
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        padding-right: 30px; /* Adjust this based on your icon size */
    }
    .select-container .fa-chevron-down {
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        pointer-events: none; /* Allows clicking through the icon to the select element */
    }
</style>


<body>
    <div class="wrapper">
        <?php 
        include "sidebar.php";
        ?>

        <div class="main">
            <nav class="navbar navbar-expand px-3 border-bottom">
                <button class="btn" id="sidebar-toggle" type="button">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="navbar-collapse navbar">
                    <ul class="navbar-nav">
                    <div class="mb-3" style="margin-right:30px">
                    <h4 style="font-size:25px">ဝယ်စာရင်း</h4>
                    </div>
                        <li class="nav-item dropdown">
                            <a href="#" data-bs-toggle="dropdown" class="nav-icon pe-md-0">
                                <img src="image/logo.png" class="avatar img-fluid rounded" alt="">
                            </a>
                            <?php include "logo_profile.php";?>
                        </li>
                    </ul>
                </div>
            </nav>

            <main class="content px-3 py-2">
                <div class="container-fluid">

                <div class="mb-3" style="position: relative;">
                
                    
                </div>


                    <div class="row">
                  
                    <!-- Table Element -->
                    <div class="container-fluid">

                    <div class="card-header gx-5">
                        <form class="d-flex flex-row-reverse ">
                        <div class="col-auto" style="margin-left:10px">
                            <input type="text" class="form-control" id="searchInput" placeholder="Search">
                        </div>
                        <div class="col-auto">
                            <button type="submit" class="btn btn-primary mb-3"><i class="fa-solid fa-magnifying-glass"></i></button>
                        </div>
                        </form>
                        </div>

                        <div class="scrollable-table" style="height:70vh;">
                            <table class="table table-bordered table-hover" style="color:white;font-size:18px;"  id="dataTable">
                            <thead style="background-color:#19242e">
                            <tr>
                            <th class="data-fixed-columns" scope="col">id</th>
                            <th scope="col">ပေါင်ချာနံပါတ်</th>
                            <th scope="col">ဝယ်သူအမည်</th>
                            <th scope="col">ပစ္စည်းအမည်</th>
                            <th scope="col">ရောင်းဈေး</th>
                            <th scope="col">ပမာဏ</th>
                            <th scope="col">စုစုပေါင်း</th>
                            </tr>
                            </thead>
                                <tbody>
                                    <?php 
                                    $sql = "Select * from ".$sell_data." where customer != 'imv_customer'";
                                    $result = mysqli_query($connection, $sql);
                                    if ($result) {
                                        while ($row = mysqli_fetch_assoc($result)) {
                                            echo '<tr>
                                            <td>' . $row['id']. '</td>
                                            <th scope="row">' . $row['voucher']. '</th>
                                            <td>' . $row['customer'] . '</td>
                                            <td>' . $row['product_name'] . '</td>
                                            <td>' . number_format($row['price']/$row['rate']) . '</td>
                                            <td>' . $row['qty'] . '</td>
                                            <td>' . number_format($row['total']/$row['rate']) . '</td>                                     
                                            </tr>';
                                        }
                                        mysqli_free_result($result);
                                    }
                                    ?>
     
                                </tbody>
                            </table>  
                        </div>
                    </div>


                     <!-- End Table Element -->
                      <div class="container-fluid"> 
                      <div class="row justify-content-center" style='margin:0px;'> 
                        <h1 style="margin:10px 0px 15px 10px;font-size:30px;text-align:center">ဖောက်သည်စာရင်း</h1>

                        <!-- =================cont_1================================ -->
                        
                        <?php
                        include "database/database.php";
                        // Fetch all image data from the database
                        $sql = "SELECT * FROM ".$customer." order by total_buy desc";
                        $result = $connection->query($sql);

                        if ($result->num_rows > 0) {
                            while ($row = $result->fetch_assoc()) {
                        
    
                                echo '
                                <div class="col-sm-4" style="border-radius:10px; width:350px; margin:10px">
                                    <div class="card mb-3">
                                        <div class="card-header bg-info text-white">
                                            <h5 class="card-title">'.$row["name"].'</h5>
                                        </div>
                                        <div class="card-body">
                                           
                                  
                                            
                                            <table class="table table-borderless">
                                                <tr>
                                                <th><a style="font-size:20px">ဝယ်အား -</a></th>
                                                <th><a style="color:white;font-size:20px">'.number_format($row["total_buy"]).' '.$row['currency'].'</a></th>
                                                </tr>

                                                <tr>
                                                <th><a style="font-size:20px">အကြွေး -</a></th>
                                                <th><a style="color:white;font-size:20px">'.number_format($row["debt"]).' '.$row['currency'].'</a></th>
                                                </tr>

                                                <tr>
                                                <th><a style="font-size:20px">ပေးချေပြီး -</a></th>
                                                <th><a style="color:white;font-size:20px">'.number_format($row["pay"]).' '.$row['currency'].'</a></th>
                                                </tr>

                                                <tr>
                                                <th><a style="font-size:20px">ပေးရန်ကျန် -</a></th>
                                                <th><a style="color:white;font-size:20px">'.number_format($row["remain_debt"]).' '.$row['currency'].'</a></th>
                                                </tr>

                                            </table>
                                            
                                        </div>

                                    </div>
                                </div>
                                ';
                            }
                        } else {
                            echo "No images found.";
                        }
                        ?>

                    </div>

                    <table class="table table-borderless">
                        <tr>
                        <th></th>
                        <th></th>
                        </tr>

                    </table>



                    <!-- End Photo Element -->

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


            <a href="#" class="theme-toggle">
                <i class="fa-regular fa-moon"></i>
                <i class="fa-regular fa-sun"></i>
            </a>
            <footer class="footer">
                <div class="container-fluid">
                    <div class="row text-muted">
                        <div class="col-6 text-start">
                            <p class="mb-0">
                                <a href="#" class="text-muted">
                                    <?php 
                                        include "version.php";
                                    ?>
                                </a>
                            </p>
                        </div>
                        <div class="col-6 text-end">
                            <ul class="list-inline">
                                <li class="list-inline-item">
                                    <a href="#" class="text-muted">Contact</a>
                                </li>
                                <li class="list-inline-item">
                                    <a href="#" class="text-muted">About Us</a>
                                </li>
                                <li class="list-inline-item">
                                    <a href="#" class="text-muted">Terms</a>
                                </li>
                                <li class="list-inline-item">
                                    <a href="#" class="text-muted">Booking</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </footer>
        </div>
    </div>
    

<?php 

function generateUniqueBrowserId()
{
    $randomString = bin2hex(random_bytes(16));
    $timestamp = time();

    return $randomString . $timestamp;
}

?>
<script src="js/script.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

</body>

</html>
