<?php $__env->startSection('content'); ?>

<?php 

$inactive_users = DB::table('users')->where('status', 0)->get()->count();
$free_agents = DB::table('users')->where('status', 'free_agent')->get()->count();
$active_users = DB::table('users')->where('status', 1)->get()->count();
$all_users = DB::table('users')->get()->count();
$total_balance = DB::table('users')->get()->sum('balance');

$total_ref_com = DB::table('users')->get()->sum('wallet');

$syscapital = DB::table('invest')->get()->sum('capital');

$syspackages = DB::table('invest')->get()->count();

$sysdailyincome = DB::table('invest')->get()->sum('daily_income');

$days  = DB::table('invest')->get()->sum('days_paid');

$cashouts = DB::table('cashouts')->get()->sum('amount');

$pending_cashouts = DB::table('cashouts')->where('status', 'pending')->get()->count();

$commissions = ($cashouts + $total_balance);

$deposits = DB::table('deposits')->get()->sum('amount');

// Set the timezone to match your database's timezone


// Get today's date at 4 am
$today = \Carbon\Carbon::today();

// Fetch deposits since 4 am
$todaysDeposit = DB::table('deposits')
    ->where('created_at', '>=', $today)
    ->sum('amount');

// Fetch withdrawals since 4 am
$todaysWithdrawals = DB::table('cashouts')
    ->where('created_at', '>=', $today)
    ->sum('amount');





?>

    <div class="col-xl-3 col-md-6">
        <div class="card bg-dark update-card">
            <center>
                <div class="card-header">
                 Todays Progress Admin
             </div>
             <?php echo e($today); ?>

            </center>
             
            <div class="card-body">
                <div class="row ">
                    <div class="col-6 text-center"><p>TODAYS INCOME: KES.<?php echo e($todaysDeposit); ?> </p></div>
                     <div class="col-6 text-center"><p>TODAYS OUTCOME: KES.<?php echo e($todaysWithdrawals); ?></p> </div>
                 
                      
                   
                </div>
                
               
            </div>
            <div class="card-footer">
                   <center>
                            REVENUE
                            <h3><b>
                                KES.<?php echo e(number_format($todaysDeposit - $todaysWithdrawals)); ?>

                                </b>
                            </h3>
                  </center>
            </div>

        </div>
    </div>
    
    
    <div class="col-xl-3 col-md-6">
        <div class="card bg-primary update-card">
            <div class="card-block">
                <div class="row align-items-end">
                    <div class="col-12">
                        <h4 class="text-white"><?php echo e($all_users); ?></h4>
                        <h6 class="text-white m-b-0">Total Users</h6>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <a href="users/all" class="text-white m-b-0">
                    <i class="feather icon-clock text-white f-14 m-r-10"></i><b><u>View
                            All</u></b></a>
            </div>
        </div>
    </div>
    <div class="col-xl-3 col-md-6">
        <div class="card bg-danger update-card">
            <div class="card-block">
                <div class="row align-items-end">
                    <div class="col-12">
                        <h4 class="text-white"><?php echo e($active_users); ?></h4>
                        <h6 class="text-white m-b-0">Active Users</h6>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <a href="users/active" class="text-white m-b-0">
                    <i data-feather="clock text-white f-14 m-r-10"></i>
                    <b><u>View All</u></b></a>
            </div>
        </div>
    </div>
    <div class="col-xl-3 col-md-6">
        <div class="card bg-success update-card">
            <div class="card-block">
                <div class="row align-items-end">
                    <div class="col-12">
                        <h4 class="text-white"><?php echo e($inactive_users); ?></h4>
                        <h6 class="text-white m-b-0">Dormant Users</h6>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <a href="users/inactive" class="text-white m-b-0"><i
                        class="feather icon-clock text-white f-14 m-r-10"></i><b><u>View
                            All</u></b></a>
            </div>
        </div>
    </div>
    <div class="col-xl-3 col-md-6">
        <div class="card bg-dark update-card">
            <div class="card-block">
                <div class="row align-items-end">
                    <div class="col-12">
                        <h4 class="text-white">KES.<?php echo e(number_format($total_balance, 2 )); ?></h4>
                        <h6 class="text-white m-b-0">User Balance</h6>
                    </div>

                </div>
            </div>
            <div class="card-footer">
                <a href="users/all" class="text-white m-b-0"><i
                        class="feather icon-clock text-white f-14 m-r-10"></i><b><u>View
                            All</u></b></a>
            </div>
        </div>
    </div>
    <div class="col-xl-3 col-md-6">
        <div class="card bg-dark update-card">
            <div class="card-block">
                <div class="row align-items-end">
                    <div class="col-12">
                        <h4 class="text-white"> KES.<?php echo e(number_format($deposits, 2)); ?></h4>
                        <h6 class="text-white m-b-0">Total Deposits</h6>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <a href="deposits/all" class="text-white m-b-0"><i
                        class="feather icon-clock text-white f-14 m-r-10"></i><b><u>View
                            All</u></b></a>
            </div>
        </div>
    </div>
    <div class="col-xl-3 col-md-6">
        <div class="card bg-success update-card">
            <div class="card-block">
                <div class="row align-items-end">
                    <div class="col-12">
                        <h4 class="text-white"> KES.<?php echo e(number_format($commissions, 2)); ?>

                        </h4>
                        <h6 class="text-white m-b-0">Total Commisions</h6>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <a href="users/all_investments" class="text-white m-b-0"><i
                        class="feather icon-clock text-white f-14 m-r-10"></i><b><u>View
                            All</u></b></a>
            </div>
        </div>
    </div>
    <div class="col-xl-3 col-md-6">
        <div class="card bg-danger update-card">
            <div class="card-block">
                <div class="row align-items-end">
                    <div class="col-12">
                        <h4 class="text-white"> KES.<?php echo e(number_format($cashouts, 2)); ?></h4>
                        <h6 class="text-white m-b-0">Total Withdrawals</h6>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <a href="withdrawals/all" class="text-white m-b-0"><i
                        class="feather icon-clock text-white f-14 m-r-10"></i><b><u>View
                            All</u></b></a>
            </div>
        </div>
    </div>
    <div class="col-xl-3 col-md-6">
        <div class="card bg-primary update-card">
            <div class="card-block">
                <div class="row align-items-end">
                    <div class="col-12">
                        <h4 class="text-white">KES.<?php echo e(number_format($pending_cashouts, 2)); ?></h4>
                        <h6 class="text-white m-b-0">Pending Withdrawals</h6>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <a href="withdrawals/pending" class="text-white m-b-0"><i
                        class="feather icon-clock text-white f-14 m-r-10"></i><b><u>View
                            All</u></b></a>
            </div>
        </div>
    </div>
    <div class="col-xl-3 col-md-6">
        <div class="card bg-primary update-card">
            <div class="card-block">
                <div class="row align-items-end">
                    <div class="col-12">

                        <h4 class="text-white"> KES.<?php echo e(number_format($total_ref_com, 2)); ?></h4>
                        <h6 class="text-white mb-0">Total Referal Commision
                        </h6>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <a href="affliates/all" class="text-white m-b-0"><i
                        class="feather icon-clock text-white f-14 m-r-10"></i><b><u>View
                            All</u></b></a>
            </div>
        </div>
    </div>
    <div class="col-xl-3 col-md-6">
        <div class="card bg-danger update-card">
            <div class="card-block">
                <div class="row align-items-end">
                    <div class="col-12">

                        <h4 class="text-white"> KES.<?php echo e(number_format($syscapital, 2)); ?>

                        </h4>
                        <h6 class="text-white m-b-0">Total Investments</h6>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <a href="users/all_investments" class="text-white m-b-0"><i
                        class="feather icon-clock text-white f-14 m-r-10"></i><b><u>View
                            All</u></b></a>
            </div>
        </div>
    </div>
    <div class="col-xl-3 col-md-6">
        <div class="card bg-success update-card">
            <div class="card-block">
                <div class="row align-items-end">
                    <div class="col-12">
                        <h4 class="text-white"><?php echo e($free_agents); ?></h4>
                        <h6 class="text-white m-b-0">Active Free Agents</h6>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <a href="/users/all" class="text-white m-b-0"><i
                        class="feather icon-clock text-white f-14 m-r-10"></i><b><u>View
                            All</u></b></a>
            </div>
        </div>
    </div>
    <div class="col-xl-3 col-md-6">
        <div class="card bg-danger update-card">
            <div class="card-block">
                <div class="row align-items-end">
                    <div class="col-12">

                        <h4 class="text-white"> <?php echo e(number_format($syspackages, 2)); ?></h4>
                        <h6 class="text-white m-b-0">Total Purchased Plans</h6>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <a href="#" class="text-white m-b-0"><i class=" text-white f-14 m-r-10"></i><b></b></a>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/uniquesq/jijenge.top/resources/views/home.blade.php ENDPATH**/ ?>