@php $gross_collection = 0; $total_commission = 0; $net_collection = 0; $total_trips = 0; $total_passenger = 0; $avarage_occupancy = 0; $total_luggages = 0; $total_expense = 0; $total_comission = 0; @endphp @foreach ($routesReport as $x => $route) @endforeach
S/N ROUTE TRIPS PASSENGERs % OCCUPANCY ROUTE FARE(TZS) GROSS COLLECTION(TZS) AGENT COMMISSION OTHER EXPENSES NET COLLECTION LUGGAGE (TZS)
{{$x+1}} @php $pA = \App\Models\Route::where(['id' => $route->id])->first()->start_point; $pB = \App\Models\Route::where(['id' => $route->id])->first()->end_point; $pointA = \App\Models\Cities::where(['id' => $pA])->first()->city; $pointB = \App\Models\Cities::where(['id' => $pB])->first()->city; if($pA == 1){ $pointA = "DAR"; }elseif ($pB == 1){ $pointB = "DAR"; } echo ''.$pointA .' - '.$pointB.''; @endphp @php $yesterday = date('Y-m-d', strtotime("-1 days")); if($route->id < 53){ $trips = \Illuminate\Support\Facades\DB::table('schedules') ->where('schedules.company', '=', 2) ->where('schedules.route_id', '=', $route->id) ->where('schedules.trip_date', $yesterday) ->where('schedules.status', "=",1) ->where('schedules.booked_seats', '>=', 35) ->count('schedules.status'); }else{ $trips = \Illuminate\Support\Facades\DB::table('schedules') ->where('schedules.company', '=', 2) ->where('schedules.route_id', '=', $route->id) ->where('schedules.trip_date', $yesterday) ->where('schedules.status', "=",1) ->where('schedules.booked_seats', '>', '0') ->count('schedules.status'); } echo $trips; $total_trips += $trips; @endphp @php $yesterday = date('Y-m-d', strtotime("-1 days")); $bookings = \Illuminate\Support\Facades\DB::table('booking_histories') ->leftJoin('schedules', function ($join) { $join->on('schedules.id', '=', 'booking_histories.schedule_id'); }) ->leftJoin('routes', function ($join) { $join->on('routes.id', '=', 'schedules.route_id'); }) ->where('booking_histories.company', '=', 2) ->where('booking_histories.status', '>', 2) ->where('schedules.trip_date', $yesterday) ->where('routes.id', '=', $route->id) ->select('booking_histories.count') ->count('booking_histories.count'); echo $bookings; $total_passenger += $bookings; @endphp @php $localTime = new \DateTime("now", new \DateTimeZone('Africa/Dar_es_Salaam')); $kifuaDate = $localTime->format('Y-m-d'); $yesterday = date('Y-m-d', strtotime("-1 days")); $from = \App\Models\Route::where('id', $route->id)->value('start_point'); $to = \App\Models\Route::where('id', $route->id)->value('end_point'); $origin = \App\Models\Cities::where('id', $from)->value('city'); $destination = \App\Models\Cities::where('id', $to)->value('city'); $fare = DB::table('sub_routes') ->where('route', '=', $route->id) ->where('pointA', '=', $origin) ->where('pointB', '=', $destination) ->where('is_deleted', '=', 0) ->max('fare'); if($route->id < 53){ $all_seats = \Illuminate\Support\Facades\DB::table('bookings') ->leftJoin('schedules', function ($join) { $join->on('schedules.id', '=', 'bookings.schedule_id'); }) ->where('bookings.company', '=', 2) ->where('schedules.trip_date', $yesterday) ->where('schedules.route_id', '=', $route->id) ->where('schedules.booked_seats', '>=', 35) ->select('bookings.count') ->sum('bookings.count'); $passenger_full_fare = \Illuminate\Support\Facades\DB::table('bookings') ->leftJoin('schedules', function ($join) { $join->on('schedules.id', '=', 'bookings.schedule_id'); }) ->leftJoin('sub_routes', function ($join) { $join->on('sub_routes.route', '=', 'schedules.route_id'); }) ->where('schedules.trip_date', $yesterday) ->where('schedules.booked_seats', '>=', 35) ->where('schedules.route_id', '=', $route->id) ->where('bookings.status', '>', 2) ->where('bookings.company', '=', 2) ->where('sub_routes.pointA', '=', $origin) ->where('sub_routes.pointB', '=', $destination) ->select('bookings.count') ->sum('bookings.count'); }else{ $all_seats = \Illuminate\Support\Facades\DB::table('bookings') ->leftJoin('schedules', function ($join) { $join->on('schedules.id', '=', 'bookings.schedule_id'); }) ->where('bookings.company', '=', 2) ->where('schedules.trip_date', $yesterday) ->where('schedules.route_id', '=', $route->id) ->select('bookings.count') ->sum('bookings.count'); $passenger_full_fare = \Illuminate\Support\Facades\DB::table('bookings') ->leftJoin('schedules', function ($join) { $join->on('schedules.id', '=', 'bookings.schedule_id'); }) ->leftJoin('sub_routes', function ($join) { $join->on('sub_routes.route', '=', 'schedules.route_id'); }) ->where('schedules.trip_date', $yesterday) ->where('schedules.route_id', '=', $route->id) ->where('bookings.status', '>', 2) ->where('bookings.company', '=', 2) ->where('sub_routes.pointA', '=', $origin) ->where('sub_routes.pointB', '=', $destination) ->where('sub_routes.route', '=', $route->id) ->where('sub_routes.is_deleted', '=', 0) ->select('bookings.count') ->sum('bookings.count'); } //dd($passenger_full_fare.' -- '.$all_seats); if($all_seats == 0){ echo '0%'; }else{ $cal = round(($passenger_full_fare/$all_seats)*100, 1); echo $cal."%"; } @endphp @php $from = \App\Models\Route::where('id', $route->id)->value('start_point'); $to = \App\Models\Route::where('id', $route->id)->value('end_point'); $origin = \App\Models\Cities::where('id', $from)->value('city'); $destination = \App\Models\Cities::where('id', $to)->value('city'); $yesterday = date('Y-m-d', strtotime("-1 days")); $fare = \Illuminate\Support\Facades\DB::table('sub_routes') ->where('sub_routes.route', $route->id) ->where('sub_routes.pointA', $origin) ->where('sub_routes.pointB', $destination) ->max('sub_routes.fare'); echo number_format($fare); @endphp @php $localTime = new \DateTime("now", new \DateTimeZone('Africa/Dar_es_Salaam')); $kifuaDate = $localTime->format('Y-m-d'); $yesterday = date('Y-m-d', strtotime("-1 days")); if($route->id < 53){ $Sales = \Illuminate\Support\Facades\DB::table('booking_histories') ->leftJoin('schedules', function ($join) { $join->on('schedules.id', '=', 'booking_histories.schedule_id'); }) ->leftJoin('sub_routes', function ($join) { $join->on('sub_routes.id', '=', 'booking_histories.sub_route_id'); }) ->leftJoin('routes', function ($join) { $join->on('routes.id', '=', 'sub_routes.route'); }) ->where('booking_histories.company', '=', 2) ->where('schedules.trip_date', $yesterday) ->where('schedules.booked_seats', '>=', 10) ->where('booking_histories.status', '>', 2) ->where('routes.id', '=', $route->id) ->select('booking_histories.fullname as passenger', 'booking_histories.msisdn', 'booking_histories.status', 'booking_histories.booking_date') ->sum('booking_histories.fare'); }else{ $Sales = \Illuminate\Support\Facades\DB::table('booking_histories') ->leftJoin('schedules', function ($join) { $join->on('schedules.id', '=', 'booking_histories.schedule_id'); }) ->leftJoin('sub_routes', function ($join) { $join->on('sub_routes.id', '=', 'booking_histories.sub_route_id'); }) ->leftJoin('routes', function ($join) { $join->on('routes.id', '=', 'sub_routes.route'); }) ->where('booking_histories.company', '=', 2) ->where('schedules.trip_date', $yesterday) ->where('booking_histories.status', '>', 2) ->where('routes.id', '=', $route->id) ->select('booking_histories.fullname as passenger', 'booking_histories.msisdn', 'booking_histories.status', 'booking_histories.booking_date') ->sum('booking_histories.fare'); } echo number_format($Sales); $gross_collection += $Sales; @endphp @php $localTime = new \DateTime("now", new \DateTimeZone('Africa/Dar_es_Salaam')); $kifuaDate = $localTime->format('Y-m-d'); $yesterday = date('Y-m-d', strtotime("-1 days")); $commission = \Illuminate\Support\Facades\DB::table('booking_histories') ->leftJoin('schedules', function ($join) { $join->on('schedules.id', '=', 'booking_histories.schedule_id'); }) ->leftJoin('sub_routes', function ($join) { $join->on('sub_routes.id', '=', 'booking_histories.sub_route_id'); }) ->leftJoin('routes', function ($join) { $join->on('routes.id', '=', 'sub_routes.route'); }) ->leftJoin('agent_companies', function ($join) { $join->on('agent_companies.agent', '=', 'booking_histories.agent_id'); }) ->where('booking_histories.company', '=', 2) ->where('schedules.trip_date', $yesterday) ->where('booking_histories.status', '>', 2) ->where('routes.id', '=', $route->id) ->where('agent_companies.type', '=', 2) ->select('sub_routes.fixedCommission') ->sum('sub_routes.fixedCommission'); echo number_format($commission); $total_commission += $commission; @endphp
Total: {{ $total_trips }} {{ $total_passenger }} {{number_format($gross_collection, 0)}}/- {{number_format($total_commission, 0)}}/-

ONLINE :

Mpesa = 0/-
Tigopesa = 0/-
AirtelMoney = 0/-
Halopesa = 0/-

CASH :

BANK :

Powered By: TiketiGala - https://www.aboodbus.co.tz