@extends('admin.layouts.app') @section('title', 'Agents Report') @section('content')
@foreach($bs as $i => $booking) @endforeach
SN AGENT TODAY YESTERDAY THIS WEEK LAST WEEK THIS MONTH LAST MONTH YEAR LAST YEAR
{{$i+1}} @if($booking->agent_id == 0) TiketiGala @else {{ \App\Models\Agent::where(['id' => $booking->agent_id])->first()->name }} @endif @php $fareT = \App\Models\Booking::whereDate('created_at', \Illuminate\Support\Carbon::today()) ->where('agent_id', '=', $booking->agent_id) ->where('status', '>', 2) ->sum('fare'); echo $fareT; @endphp @php $fareLD = \App\Models\Booking::whereDate('created_at', \Illuminate\Support\Carbon::yesterday()->toDateString()) ->where('agent_id', '=', $booking->agent_id) ->where('status', '>', 2) ->sum('fare'); echo $fareLD; @endphp @php $fareW = \App\Models\Booking::whereBetween('created_at', [\Illuminate\Support\Carbon::now()->startOfWeek(), \Illuminate\Support\Carbon::now()->endOfWeek()]) ->where('agent_id', '=', $booking->agent_id) ->where('status', '>', 2) ->sum('fare'); echo $fareW; @endphp @php $previous_week = strtotime("-1 week +1 day"); $start_week = strtotime("last sunday midnight",$previous_week); $end_week = strtotime("next saturday",$start_week); $start_week = date("Y-m-d",$start_week); $end_week = date("Y-m-d",$end_week); $fareLW = \App\Models\Booking::whereBetween('created_at', [$start_week, $end_week]) ->where('agent_id', '=', $booking->agent_id) ->where('status', '>', 2) ->sum('fare'); echo $fareLW; @endphp @php $fareM = \App\Models\Booking::whereMonth('created_at', date('m')) ->where('agent_id', '=', $booking->agent_id) ->where('status', '>', 2) ->sum('fare'); echo $fareM; @endphp @php $fareLM = \App\Models\Booking::whereMonth('created_at', '=', \Illuminate\Support\Carbon::now()->subMonth()->month) ->where('agent_id', '=', $booking->agent_id) ->where('status', '>', 2) ->sum('fare'); echo $fareLM; @endphp @php $fareW = \App\Models\Booking::whereYear('created_at', date('Y')) ->where('agent_id', '=', $booking->agent_id) ->where('status', '>', 2) ->sum('fare'); echo $fareW; @endphp @php $fareW = \App\Models\Booking::whereYear('created_at', date('Y', strtotime('-1 year'))) ->where('agent_id', '=', $booking->agent_id) ->where('status', '>', 2) ->sum('fare'); echo $fareW; @endphp
@csrf
  • Total Ticket Sold
    {{ $totalAgents }}
{{--
    --}} {{-- @foreach ($trips as $x => $trip)--}} {{--
  • --}} {{--
    --}} {{--
    --}} {{--
    --}} {{--
    --}} {{--
    --}} {{-- @php--}} {{-- $pA = \App\Models\Route::where(['id' => $trip->route_id])->first()->start_point;--}} {{-- $pB = \App\Models\Route::where(['id' => $trip->route_id])->first()->end_point;--}} {{-- $pointA = \App\Models\Cities::where(['id' => $pA])->first()->city;--}} {{-- $pointB = \App\Models\Cities::where(['id' => $pB])->first()->city;--}} {{-- echo $pointA .' - '.$pointB;--}} {{-- @endphp--}} {{--
    --}} {{--
    --}} {{--
    --}} {{--
    --}} {{--
    --}} {{-- @php--}} {{-- $localTime = new \DateTime("now", new \DateTimeZone('Africa/Dar_es_Salaam'));--}} {{-- $kifuaDate = $localTime->format('Y-m-d');--}} {{-- $bookings = \Illuminate\Support\Facades\DB::table('bookings')--}} {{-- ->selectRaw('DATE_FORMAT(updated_at, "Y-m-d") as day, count(id) as count')--}} {{-- ->whereDate('updated_at', $kifuaDate)--}} {{-- ->where('schedule_id', $trip->id)--}} {{-- ->where('status', '>', '1')--}} {{-- ->count();--}} {{-- echo $bookings;--}} {{-- @endphp--}} {{-- --}} {{--
    --}} {{--
    --}} {{--
    --}} {{--
    --}} {{--
    --}} {{--
  • --}} {{-- @endforeach--}} {{--
--}}
AGENTS
AGENTS REPORTS TODAY @php $localTime = new \DateTime("now", new \DateTimeZone('Africa/Dar_es_Salaam')); $today = $localTime->format('d-M-Y'); echo $today; @endphp SALES
  • Total Agents
    {{ $totalAgents }}
  • Non-commission Agents
    {{ $nonCommisionAgents }}
  • Commission Agents
    {{ $commisionAgents }}
    @foreach ($agents as $x => $agent)
  • @php $name = \App\Models\Agent::where(['id' => $agent->agent])->first()->name; echo $name; @endphp
    @php $localTime = new \DateTime("now", new \DateTimeZone('Africa/Dar_es_Salaam')); $kifuaDate = $localTime->format('Y-m-d'); $bookings = \Illuminate\Support\Facades\DB::table('bookings') ->selectRaw('DATE_FORMAT(updated_at, "Y-m-d") as day, count(id) as count') ->whereDate('updated_at', $kifuaDate) ->where('agent_id', $agent->agent) ->where('status', '>', '2') ->count(); echo $bookings; @endphp
  • @endforeach
@endsection