
<!----------------------------------Login------------------------------------>
<?php
session_start();
include 'php/db_connection.php';

// শুধুমাত্র লগইন করা ইউজার পেজ দেখতে পারবে
if (!isset($_SESSION['user_id'])) {
    header("Location: login.php");
    exit();
}

$userName = $_SESSION['user_name'];
$role = $_SESSION['role']; // ✅ এখানে role সেভ করা হচ্ছে
$userId = $_SESSION['user_id'];


$isAdmin = ($_SESSION['role'] == 'admin');

?>

<!----------------------------------Reprot Link------------------------------------>
<?php include 'sidebar.php'; ?>
<?php include 'cost.php'; ?>
<?php include 'php/1_7_30_day_report.php';?>
<?php include 'php/Tppfor_7_d_.php';?>
<?php include 'php/totalQuantity_reprot.php';?>
<?php include 'php/total_customar.php';?>


        <div class="overview mt-4">
            <div class="boxes row">
                <div class="col-lg-4 col-md-6 mb-4">
                    <div class="box">
                        <i class="fas fa-chart-bar"></i>
                        <span class="text">Today Sales </span>
                        <div class="number"><P><?php echo number_format($total_today, ); ?> Tk</P></div>
                    </div>
                </div>
                <div class="col-lg-4 col-md-6 mb-4">
                    <div class="box">
                        <i class="fas fa-shopping-cart"></i>
                        <span class="text">Total Sales </span>
<!----------------------------------------------------বিক্রয় মুল্য----------------------------------------------->
<!-----লগইন এডমিন এবং ইউজার------->

<div class="number"><?php echo number_format($total_last_30_days,); ?> Tk</div>

<!----------------------------------------------------ক্রয় মুল----------------------------------------------->
                        <div class="number"><p><?php  $thirty_days_total; ?></p></div>
                        
                    </div>
                </div>
                <div class="col-lg-4 col-md-6 mb-4">
                    <div class="box">
                         <i class="fas fa-book"></i>
                        <span class="text">Total Purchase</span>
                        <?php if ($isAdmin): ?>
                        <div class="number"><p><?php echo number_format($totalPurchasePrice,); ?> Tk</p></div>
                        <?php else: ?>
                    <span class="text-muted">No Permission</span>
                    <?php endif; ?>
                    </div>
                    
                </div>
                <div class="col-lg-4 col-md-6 mb-4">
                    <div class="box">
                         <i class="fas fa-wallet"></i>
                         <!--------------------------------------------------খরছ---------------------------------------------->
                        <span class="text">Total Cost</span>
                        <?php if ($isAdmin): ?>
                        <div class="number"><p><?php echo number_format($total_tk, ); ?> Tk</p></div>
                        <?php else: ?>
                    <span class="text-muted">No Permission</span>
                    <?php endif; ?>
                    </div>
                </div>
                <!--------------------------------------------------লাভ লস--------------------------------------------->
                    <?php
                    $profit= $defarence;
                    $cost=  number_format($total_tk, );
                    $final_profit= $profit -$cost;
                    ?>

                <div class="col-lg-4 col-md-6 mb-4">
                    <div class="box">
                         <i class="fas fa-book"></i>
                        <span class="text">Profit</span>
                        <?php if ($isAdmin): ?>
                        <div class="number"><?php echo $final_profit ; ?> Tk</p></div>
                        <?php else: ?>
                    <span class="text-muted">No Permission</span>
                    <?php endif; ?>
                    </div>
                </div>
                <div class="col-lg-3 col-md-6 mb-4">
                    <div class="box">
                         <i class="fas fa-shop"></i>
                        <span class="text">Total Products</span>
                        <div class="number"><?php echo $totalQuantity; ?></div>
                    </div>
                </div>
                <div class="col-lg-3 col-md-6 mb-4">
                    <div class="box">
                         <i class="fas fa-user"></i>
                        <span class="text">Total Suppliers</span>
                        <div class="number"><?php echo $total_suppliers; ?></div>
                    </div>
                </div>
                <div class="col-lg-3 col-md-6 mb-4">
                    <div class="box">
                         <i class="fas fa-user"></i>
                        <span class="text">Total Customers</span>
                        <div class="number"><?php echo $total_customers; ?></div>
                    </div>
                </div>
            </div>
        </div>
    
        <div class="recent-sales mt-5">
            <?php include 'resent_sales.php';
                  include 'footer.php';
            ?>
        </div>
    </div>
 
