<?php include("auth.php");

require("conn.php");

$vid=$_SESSION['user_id'];
 
   
function getWallet($v_code)
{
    include "conn.php";
    $total=0;
	$query="select wallet as tot from tbl_vendor where v_code='$v_code' ";
	$smt1=mysqli_query($conn,$query);
	if($result=mysqli_fetch_assoc($smt1))
	{
	 if($result['tot'])
	 $total=$result['tot'];
	}
    return($total);
		  
}

function getTotalPayments($vid)
{
    include "conn.php";
    $total=0;
	$query="select sum(amount) as tot from payment where vendor_id='$vid'";
	$smt1=mysqli_query($conn,$query);
	if($result=mysqli_fetch_assoc($smt1))
	{
	 if($result['tot'])
	 $total=$result['tot'];
	}
    return($total);
		  
}
                                  
                                        
                                       
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">

    <title>Dashboard</title>
    <meta content="" name="description">
    <meta content="" name="keywords">
    <link href="assets/img/favicon.png" rel="icon">
    <link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
    <?php include("templates/inc.php"); ?>
    <!--  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>-->
    <!--  <script>-->
    <!--  let text = document.getElementById('myText').innerHTML;-->
    <!--  const copyContent = async () => {-->
    <!--    try {-->
    <!--      await navigator.clipboard.writeText(text);-->
    <!--      console.log('Content copied to clipboard');-->
    <!--    } catch (err) {-->
    <!--      console.error('Failed to copy: ', err);-->
    <!--    }-->
    <!--  }-->
    <!--</script>-->


</head>

<body>

    <!-- ======= Header ======= -->
    <?php
  include("templates/header.php");
  ?>

    <!-- End Header -->

    <!-- ======= Sidebar ======= -->

    <?php
  include("templates/sidebar.php");

  ?>


    <!-- End Sidebar-->

    <main id="main" class="main">

        <div class="pagetitle">
            <h1>Dashboard</h1>
            <nav>
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="index.html">Home</a></li>
                    <li class="breadcrumb-item">Dashboard</li>

                </ol>
            </nav>


        </div><!-- End Page Title -->


        <section class="section dashboard">
            <div class="row">

                <!-- Left side columns -->
                <div class="col-lg-12">
                    <div class="row">

                        <!-- Leads Card -->
                        <div class="col-xxl-6 col-md-6">
                            <div class="card info-card revenue-card">
                                <div class="card-body">
                                    <br>
                                    <div class="d-flex align-items-center"><a href="wallet-list.php">
                                            <div
                                                class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                                                <i class="bi bi-wallet2"></i>
                                            </div>
                                        </a>
                                        <div class="ps-3"><a href="wallet-list.php">
                                                <h5>Wallet: <b><?php echo getWallet($v_code) ?></b></h5>
                                            </a>

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

                            </div>
                        </div><!-- End Leads Card -->


                        <!-- follow Card -->
                        <div class="col-xxl-6 col-md-6">
                            <div class="card info-card revenue-card">



                                <div class="card-body">
                                    <br>
                                    <div class="d-flex align-items-center"><a href="payments.php">
                                            <div
                                                class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                                                <i class="bi bi-cash-stack"></i>
                                            </div>
                                        </a>
                                        <div class="ps-3"><a href="payments.php">
                                                <h5>Total Payments: <b><?php echo getTotalPayments($vid); ?></b></h5>
                                            </a>

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

                            </div>
                        </div><!-- End Revenue Card -->

                        
                        <!--<br>-->

                        <!-- <h4 style="color:Black;">Register to Get free Counselling and Demo Class</h4>-->
                        <!--<a href="get-free-counselling.php" style="color:Red;">Click To register -></a>-->




                    </div>
                </div>

            </div>
        </section>
        <br><br><br>

    </main><!-- End #main -->
    <!-- ======= Footer ======= -->
    <?php
  include("templates/footer.php");
  ?>

    <!-- End Footer -->


    <?php include("templates/vendors.php"); ?>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script>
    let text = document.getElementById('myText').innerHTML;
    const copyContent = async () => {
        try {
            await navigator.clipboard.writeText(text);
            console.log('Content copied to clipboard');
            alert("Link Copied");
            window.location = "dashboard.php";
        } catch (err) {
            console.error('Failed to copy: ', err);
        }
    }
    </script>

</body>


</html>