@php
    $admin=App\Models\Admin::where('id',Auth::guard('admin')->user()->id)->first();
@endphp
@if ($admin->hasRole('superadmin'))
    @if($datacal->web_id=='All')
    <div class="mb-4 row g-4">
        <div class="card card-body">
            <h4>Courier Profit</h4>
            <div class="row">


                <div class="col-sm-6 col-xl-3">
                    <div class="p-4 rounded bg-secondary d-flex align-items-center justify-content-between">
                        <div class="ms-3">
                            <p class="mb-2">Total Profit</p>
                            <h6 class="mb-0" id="account">{{ \App\Models\Order::where('courier_charge','>',0)->get()->sum('deliveryCharge') -\App\Models\Order::where('courier_charge','>',0)->get()->sum('courier_charge') }} TK</h6>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6 col-xl-3">
                    <div class="p-4 rounded bg-secondary d-flex align-items-center justify-content-between">
                        <div class="ms-3">
                            <p class="mb-2">This Month</p>
                            <h6 class="mb-0" id="account">{{ \App\Models\Order::whereMonth('created_at', \Carbon\Carbon::now()->month)->where('courier_charge','>',0)->get()->sum('deliveryCharge') -\App\Models\Order::whereMonth('created_at', \Carbon\Carbon::now()->month)->where('courier_charge','>',0)->get()->sum('courier_charge') }} TK</h6>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6 col-xl-3">
                    <div class="p-4 rounded bg-secondary d-flex align-items-center justify-content-between">
                        <div class="ms-3">
                            <p class="mb-2">Today</p>
                            <h6 class="mb-0" id="account">{{ \App\Models\Order::whereDate('created_at', \Carbon\Carbon::today())->where('courier_charge','>',0)->get()->sum('deliveryCharge') -\App\Models\Order::whereDate('created_at', \Carbon\Carbon::today())->where('courier_charge','>',0)->get()->sum('courier_charge') }} TK</h6>
                        </div>
                    </div>
                </div>


             </div>
        </div>
    </div>
    @else
    <div class="mb-4 row g-4">
        <div class="card card-body">
            <h4>Courier Profit</h4>
            <div class="row">
                <div class="col-sm-6 col-xl-3">
                    <div class="p-4 rounded bg-secondary d-flex align-items-center justify-content-between">
                        <div class="ms-3">
                            <p class="mb-2">Total Profit</p>
                            <h6 class="mb-0" id="account">{{ \App\Models\Order::where('web_id',$datacal->web_id)->where('courier_charge','>',0)->get()->sum('deliveryCharge') -\App\Models\Order::where('web_id',$datacal->web_id)->where('courier_charge','>',0)->get()->sum('courier_charge') }} TK</h6>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6 col-xl-3">
                    <div class="p-4 rounded bg-secondary d-flex align-items-center justify-content-between">
                        <div class="ms-3">
                            <p class="mb-2">This Month</p>
                            <h6 class="mb-0" id="account">{{ \App\Models\Order::where('web_id',$datacal->web_id)->whereMonth('created_at', \Carbon\Carbon::now()->month)->where('courier_charge','>',0)->get()->sum('deliveryCharge') -\App\Models\Order::where('web_id',$datacal->web_id)->whereMonth('created_at', \Carbon\Carbon::now()->month)->where('courier_charge','>',0)->get()->sum('courier_charge') }} TK</h6>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6 col-xl-3">
                    <div class="p-4 rounded bg-secondary d-flex align-items-center justify-content-between">
                        <div class="ms-3">
                            <p class="mb-2">Today</p>
                            <h6 class="mb-0" id="account">{{ \App\Models\Order::where('web_id',$datacal->web_id)->whereDate('created_at', \Carbon\Carbon::today())->where('courier_charge','>',0)->get()->sum('deliveryCharge') -\App\Models\Order::where('web_id',$datacal->web_id)->whereDate('created_at', \Carbon\Carbon::today())->where('courier_charge','>',0)->get()->sum('courier_charge') }} TK</h6>
                        </div>
                    </div>
                </div>


             </div>
        </div>
    </div>
    @endif
@endif

@php
$depos=App\Models\Expensetype::where('type','Deposit')->get();
$expens=App\Models\Expensetype::where('type','Expense')->get();
@endphp

<div class="mb-4 row g-4">
    <div class="card card-body">
        <div class="row">
            @forelse($depos as $depo)
                <div class="mb-2 col-sm-6 col-xl-3">
                    <a href="{{url('admin/account-deposit',$depo->expenseTypeName)}}">
                        <div class="p-4 rounded bg-secondary d-flex align-items-center justify-content-between">
                            <img src="{{asset('public/money.png')}}" style="width:50px;">
                            <div class="ms-3">
                                <p class="mb-2">{{$depo->expenseTypeName}}</p>
                                @if($datacal->web_id=='All')
                                    <h6 class="mb-0"><span id="account{{$depo->id}}">{{ \DB::table('accounts')->where('form', $depo->expenseTypeName)->whereBetween('date', [$datacal->infodate, $datacal->infodateto])->get()->sum('amount')}}</span> TK</h6>
                                @else
                                    <h6 class="mb-0"><span id="account{{$depo->id}}">{{ \DB::table('accounts')->where('website_id',$datacal->web_id)->where('form', $depo->expenseTypeName)->whereBetween('date', [$datacal->infodate, $datacal->infodateto])->get()->sum('amount')}}</span> TK</h6>
                                @endif

                            </div>
                        </div>
                    </a>
                </div>
            @empty
            @endforelse

            <div class="mb-2 col-sm-6 col-xl-3">
                <a href="{{url('admin/account-deposit/Total')}}">
                    <div class="p-4 rounded bg-secondary d-flex align-items-center justify-content-between">
                        <img src="{{asset('public/icon/income.png')}}" style="width:50px;">
                        <div class="ms-3">
                            <p class="mb-2">Total Payment </p>
                            @if($datacal->web_id=='All')
                            <h6 class="mb-0"><span id="totalpayment">{{\DB::table('accounts')->whereBetween('date', [$datacal->infodate, $datacal->infodateto])->get()->sum('amount')}}</span> TK</h6>
                            @else
                            <h6 class="mb-0"><span id="totalpayment">{{\DB::table('accounts')->where('website_id',$datacal->web_id)->whereBetween('date', [$datacal->infodate, $datacal->infodateto])->get()->sum('amount')}}</span> TK</h6>

                            @endif
                        </div>
                    </div>
                </a>
            </div>
        </div>
    </div>
</div>
<div class="mb-4 row g-4">
    <div class="card card-body">
        <div class="row">
            @forelse($expens as $expen)
                <div class="mb-2 col-sm-6 col-xl-3">
                    <a href="{{url('admin/expense-cost',$expen->expenseTypeName)}}">
                    <div class="p-4 rounded bg-secondary d-flex align-items-center justify-content-between">
                        <img src="{{asset('public/expense.png')}}" style="width:50px;">
                        <div class="ms-3">
                            <p class="mb-2">{{$expen->expenseTypeName}}</p>
                            @if($datacal->web_id=='All')
                            <h6 class="mb-0"><span id="expence{{$expen->id}}">{{\DB::table('expenses')->where('type', $expen->expenseTypeName)->whereBetween('date', [$datacal->infodate, $datacal->infodateto])->get()->sum('amount')}}</span> TK</h6>
                            @else
                            <h6 class="mb-0"><span id="expence{{$expen->id}}">{{\DB::table('expenses')->where('website_id',$datacal->web_id)->where('type', $expen->expenseTypeName)->whereBetween('date', [$datacal->infodate, $datacal->infodateto])->get()->sum('amount')}}</span> TK</h6>

                            @endif
                        </div>
                    </div>
                    </a>
                </div>
            @empty
            @endforelse

            <div class="mb-2 col-sm-6 col-xl-3">
                <a href="{{url('admin/expense-cost/Total Cost')}}">
                <div class="p-4 rounded bg-secondary d-flex align-items-center justify-content-between">
                    <img src="{{asset('public/reduction.png')}}" style="width:50px;">
                    <div class="ms-3">
                        <p class="mb-2">Total Cost</p>
                        @if($datacal->web_id=='All')
                        <h6 class="mb-0"><span id="totalcost">{{\DB::table('expenses')->whereBetween('date', [$datacal->infodate, $datacal->infodateto])->get()->sum('amount')}}</span> TK</h6>
                        @else
                        <h6 class="mb-0"><span id="totalcost">{{\DB::table('expenses')->where('website_id',$datacal->web_id)->whereBetween('date', [$datacal->infodate, $datacal->infodateto])->get()->sum('amount')}}</span> TK</h6>

                        @endif

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