<?php
session_start();
include 'class/ClassForm.php';
$query = "SELECT count(*) as invoices,remarks,b.email_id,b.user_Name FROM qr_invdetails a
inner join login_info b on a.remarks = b.id
GROUP by a.remarks";
$result = $ClassForm->Fetch_Result_Set($query);

?>
<div class="container-fluid">
    <div class="d-sm-flex align-items-center justify-content-between mb-4">
        <h1 class="h3 mb-0 text-gray-800">Dashboard</h1>
    </div>    
    <div class="row" style="display: flex; flex-wrap:wrap;">

    
    <?php 
    while($row = mysqli_fetch_assoc($result)){
        $queryXy = "select distinct count(*) count_ from qr_invdetails where remarks = '".$row['remarks']."' and
          YEAR(date_ref) = YEAR(CURRENT_DATE()) AND 
          MONTH(date_ref) = MONTH(CURRENT_DATE()) AND
          DAY(date_ref) = DAY(CURRENT_DATE())";
        $invCont = $ClassForm->Fetch_Result_Array($queryXy);
        
        ?>
        <div class="col-xl-3 col-md-6 mb-4">
            <div class="card border-left-primary shadow h-100 py-2">
                <div class="card-body">
                    <div class="row no-gutters align-items-center">
                        <div class="col mr-2">
                            <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
                                Invoice Generated - (<?php echo $row['invoices']; ?>)</div>
                            <div class="text-xs font-weight-bold text-secondary text-uppercase mb-1">
                            <?php echo date('d M Y') ?> - (<?php echo $invCont['count_']; ?>)</div>
                            
                            <div class="h5 mb-0 font-weight-bold text-gray-800">
                                <?php echo $row['user_Name'];  ?></div>
                            <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
                                 <br/> (<?php echo $row['email_id']; ?>)</div>
                        </div>
                        <div class="col-auto">
                            <i class="fas fa-calendar fa-2x text-gray-300"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php
    }
    ?>
    </div>
</div>