<?php

namespace App\Http\Controllers\OwnerPanel;

use App\Http\Controllers\Controller;
use App\Models\User;;

use App\Models\CurrencyMaster;
use App\Models\CarWashOwner;
use App\Models\WashDetail;
use App\Models\OtherServiceReport;
use App\Models\OtherServiceReportToProduct;
use Illuminate\Http\Request;
use Auth;
use Carbon\Carbon;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\View;
use DB;

class OwnerDailySummaryReportController extends Controller
{
    public function index(Request $request)
    {
        $data['page_title'] = "Daily Summary Report";
        $data['page_sub_title'] = "Daily Summary Report";
        // $data['cards'] = $this->card_data();
        $today = date('Y-m-d');  
        $search_date = $request->input('search_date');
        if($search_date != ''){
            $date = date("Y-m-d", strtotime($search_date));
        } else {
            $date = $today;
        }  
        $data['cards'] = $this->card_data($date);
        // dd($data);
        return view('owner.daily-summary-report', $data);
    }

    protected function card_data_withOutSplit($search_date)
    {
        $cwo_id = Auth::user()->cwo_id;
        // echo $cwo_id;exit;
        $today = date('Y-m-d');  
        /*$totalCarWashed = WashDetail::join('wash_categories', 'wash_categories.id', '=', 'wash_details.wash_type_id')
            ->where('wash_categories.cwo_id', $cwo_id)
            ->where('wash_details.status', 3)
            ->count();*/
        // $search_date = $request->input('search_date');
        if($search_date != ''){
            $date = date("Y-m-d", strtotime($search_date));
        } else {
            $date = $today;
        }    

        $getCurrency = CarWashOwner::leftJoin('currency_masters', 'currency_masters.id', '=', 'cwo_master.currency_id')->select('currency_masters.code', 'currency_masters.symbol')->where('cwo_master.id', $cwo_id)->get();
        // echo "<pre>";print_r($getCurrency->toArray());exit;

        /***************** total car washed starts *********************/ 
        $todayTotalCarWashed = WashDetail::where('cwo_id', $cwo_id)
            // ->whereDate('date_washed', '=', $today)
            ->whereDate('date_washed', '=', $date)
            // ->where('status', 3)
            ->count(); 
        /***************** total car washed ends *********************/ 

        /***************** cash starts *********************/
        $todayRevenueInCash = WashDetail::select(DB::raw('SUM(wash_details.total_amount) as total_revenue'))
            ->join('cwo_master','cwo_master.id','=','wash_details.cwo_id')
            ->where('wash_details.cwo_id', $cwo_id)
            ->where('wash_details.payment_details', 'cash')
            // ->whereDate('wash_details.date_washed', '=', $today)
            ->whereDate('wash_details.date_washed', '=', $date)
            ->get();
        // echo "<pre>";print_r($todayRevenueInCash->toArray());exit;
        $todayRevenueInCash = $todayRevenueInCash[0]->total_revenue != '' ? $todayRevenueInCash[0]->total_revenue : 0;
        /***************** cash ends *********************/

        /***************** card starts *********************/
        $todayRevenueInCard = WashDetail::select(DB::raw('SUM(wash_details.total_amount) as total_revenue'))
            ->join('cwo_master','cwo_master.id','=','wash_details.cwo_id')
            ->where('wash_details.cwo_id', $cwo_id)
            // ->where('wash_details.payment_details', 'card')
            ->where('wash_details.payment_details', 'like', '%' . 'card' . '%')
            // ->whereDate('wash_details.date_washed', '=', $today)
            ->whereDate('wash_details.date_washed', '=', $date)
            ->get();
        // echo "<pre>";print_r($todayRevenueInCard->toArray());exit;
        $todayRevenueInCard = $todayRevenueInCard[0]->total_revenue != '' ? $todayRevenueInCard[0]->total_revenue : 0;
        /***************** card ends *********************/

        /***************** contract starts *********************/
        $todayRevenueInContract = WashDetail::select(DB::raw('SUM(wash_details.total_amount) as total_revenue'))
            ->join('cwo_master','cwo_master.id','=','wash_details.cwo_id')
            ->where('wash_details.cwo_id', $cwo_id)
            ->where('wash_details.payment_details', 'like', '%' . 'contract' . '%')
            // ->whereDate('wash_details.date_washed', '=', $today)
            ->whereDate('wash_details.date_washed', '=', $date)
            ->get();
        // echo "<pre>";print_r($todayRevenueInContract->toArray());exit;
        $todayRevenueInContract = $todayRevenueInContract[0]->total_revenue != '' ? $todayRevenueInContract[0]->total_revenue : 0;

        // $todayRevenueInCash = $todayRevenueInCash + $todayRevenueInContract;
        /******************* contract ends ************************/

        /***************** other products/services starts *********************/
        $totalProductsSold = OtherServiceReport::select(DB::raw('SUM(other_service_report_to_products.quantity) as total_quantity'))
                    ->join('other_service_report_to_products','other_service_reports.id','=','other_service_report_to_products.other_service_report_id')
                    ->where('other_service_reports.cwo_id', $cwo_id)
                    ->where('other_service_reports.status',1)
                    ->whereDate('other_service_reports.date', '=', $date)
                    ->get();
        // echo "<pre>";print_r($totalProductsSold->toArray());exit;
        $totalProductsSold = $totalProductsSold[0]->total_quantity != '' ? $totalProductsSold[0]->total_quantity : 0;  


        $revenueInCashOtherProducts = OtherServiceReport::select(DB::raw('SUM(other_service_reports.total_amount) as total_revenue'))
                    // ->join('cwo_master','cwo_master.id','=','other_service_reports.cwo_id')
                    ->where('other_service_reports.cwo_id', $cwo_id)
                    ->where('other_service_reports.status',1)
                    ->where('other_service_reports.payment_details', 'cash')
                    ->whereDate('other_service_reports.date', '=', $date)
                    ->get();
        // echo "<pre>";print_r($revenueInCashOtherProducts->toArray());exit;
        $revenueInCashOtherProducts = $revenueInCashOtherProducts[0]->total_revenue != '' ? $revenueInCashOtherProducts[0]->total_revenue : 0;   

        $revenueInCardOtherProducts = OtherServiceReport::select(DB::raw('SUM(other_service_reports.total_amount) as total_revenue'))
                    // ->join('cwo_master','cwo_master.id','=','other_service_reports.cwo_id')
                    ->where('other_service_reports.cwo_id', $cwo_id)
                    ->where('other_service_reports.status',1)
                    ->where('other_service_reports.payment_details', 'like', '%' . 'card' . '%')
                    ->whereDate('other_service_reports.date', '=', $date)
                    ->get();
        // echo "<pre>";print_r($revenueInCardOtherProducts->toArray());exit;
        $revenueInCardOtherProducts = $revenueInCardOtherProducts[0]->total_revenue != '' ? $revenueInCardOtherProducts[0]->total_revenue : 0;  

        $revenueInContractOtherProducts = OtherServiceReport::select(DB::raw('SUM(other_service_reports.total_amount) as total_revenue'))
                    ->join('cwo_master','cwo_master.id','=','other_service_reports.cwo_id')
                    ->where('other_service_reports.cwo_id', $cwo_id)
                    ->where('other_service_reports.status',1)
                    ->where('other_service_reports.payment_details', 'like', '%' . 'contract' . '%')
                    ->whereDate('other_service_reports.date', '=', $date)
                    ->get();
        // echo "<pre>";print_r($revenueInContractOtherProducts->toArray());exit;
        $revenueInContractOtherProducts = $revenueInContractOtherProducts[0]->total_revenue != '' ? $revenueInContractOtherProducts[0]->total_revenue : 0;                       
        /***************** other products/services ends *********************/

        $card_data = [
            
            [
                'title' => 'Total # of Cars Washed',
                'count' => $todayTotalCarWashed,
                'icon' => 'icon-credit-card',
                'color' => '#e58e95'
            ],
            [
                'title' => 'Total Cash Payments',
                'count' => $getCurrency[0]->symbol . formatCurrency($todayRevenueInCash),
                'icon' => 'icon-credit-card',
                'color' => '#90afd0'
            ],
            [
                'title' => 'Total Card Payments',
                'count' => $getCurrency[0]->symbol . formatCurrency($todayRevenueInCard),
                'icon' => 'icon-credit-card',
                'color' => '#df3657'
            ],
            [
                'title' => 'Total by Contract/EFT',
                'count' => $getCurrency[0]->symbol . formatCurrency($todayRevenueInContract),
                'icon' => 'icon-credit-card',
                'color' => '#1e89c8'
            ],
            [
                'title' => 'Total # of Products / Services Sold',
                'count' => $totalProductsSold,
                'icon' => 'icon-credit-card',
                'color' => '#ffa730'
            ],
            [
                'title' => 'Other Products/Services Cash Payments',
                'count' => $getCurrency[0]->symbol . formatCurrency($revenueInCashOtherProducts),
                'icon' => 'icon-credit-card',
                'color' => '#5dbaac'
            ],
            [
                'title' => 'Other Products/Services Card Payments',
                'count' => $getCurrency[0]->symbol . formatCurrency($revenueInCardOtherProducts),
                'icon' => 'icon-credit-card',
                'color' => '#1e89c8'
            ],
            [
                'title' => 'Other Products/Services Contract/EFT',
                'count' => $getCurrency[0]->symbol . formatCurrency($revenueInContractOtherProducts),
                'icon' => 'icon-credit-card',
                'color' => '#df3657'
            ],
        ];

        return $card_data;
    }

    protected function card_data_withOutSplitOtherServices($search_date)
    {
        $cwo_id = Auth::user()->cwo_id;
        $today = date('Y-m-d');
        if($search_date != ''){
            $date = date("Y-m-d", strtotime($search_date));
        } else {
            $date = $today;
        }    
        $getCurrency = getCurencyOfCwo($cwo_id);

        /***************** total car washed starts *********************/ 
        $todayTotalCarWashed = WashDetail::where('cwo_id', $cwo_id)
            ->whereDate('date_washed', '=', $date)
            // ->where('status', 3)
            ->count(); 
        /***************** total car washed ends *********************/ 

        /***************** cash starts *********************/
        $todayRevenueInCash = WashDetail::select(DB::raw('SUM(wash_details.cash_amount) as total_revenue'))
            ->join('cwo_master','cwo_master.id','=','wash_details.cwo_id')
            ->where('wash_details.cwo_id', $cwo_id)
            // ->where('wash_details.payment_details', 'cash')
            ->whereDate('wash_details.date_washed', '=', $date)
            ->get();
        // echo "<pre>";print_r($todayRevenueInCash->toArray());exit;
        $todayRevenueInCash = $todayRevenueInCash[0]->total_revenue != '' ? $todayRevenueInCash[0]->total_revenue : 0;
        /***************** cash ends *********************/

        /***************** card starts *********************/
        $todayRevenueInCard = WashDetail::select(DB::raw('SUM(wash_details.card_amount) as total_revenue'))
            ->join('cwo_master','cwo_master.id','=','wash_details.cwo_id')
            ->where('wash_details.cwo_id', $cwo_id)
            // ->where('wash_details.payment_details', 'card')
            // ->where('wash_details.payment_details', 'like', '%' . 'card' . '%')
            ->whereDate('wash_details.date_washed', '=', $date)
            ->get();
        // echo "<pre>";print_r($todayRevenueInCard->toArray());exit;
        $todayRevenueInCard = $todayRevenueInCard[0]->total_revenue != '' ? $todayRevenueInCard[0]->total_revenue : 0;
        /***************** card ends *********************/

        /***************** contract starts *********************/
        $todayRevenueInContract = WashDetail::select(DB::raw('SUM(wash_details.total_amount) as total_revenue'))
            ->join('cwo_master','cwo_master.id','=','wash_details.cwo_id')
            ->where('wash_details.cwo_id', $cwo_id)
            ->where('wash_details.payment_details', 'like', '%' . 'contract' . '%')
            ->whereDate('wash_details.date_washed', '=', $date)
            ->get();
        // echo "<pre>";print_r($todayRevenueInContract->toArray());exit;
        $todayRevenueInContract = $todayRevenueInContract[0]->total_revenue != '' ? $todayRevenueInContract[0]->total_revenue : 0;

        $todayRevenueInEft = WashDetail::select(DB::raw('SUM(wash_details.total_amount) as total_revenue'))
            ->join('cwo_master','cwo_master.id','=','wash_details.cwo_id')
            ->where('wash_details.cwo_id', $cwo_id)
            ->where('wash_details.payment_details', 'like', '%' . 'eft' . '%')
            ->whereDate('wash_details.date_washed', '=', $date)
            ->get();
        // echo "<pre>";print_r($todayRevenueInEft->toArray());exit;
        $todayRevenueInEft = $todayRevenueInEft[0]->total_revenue != '' ? $todayRevenueInEft[0]->total_revenue : 0;

        // $todayRevenueInCash = $todayRevenueInCash + $todayRevenueInContract;
        /******************* contract ends ************************/

        /***************** other products/services starts *********************/
        $totalProductsSold = OtherServiceReport::select(DB::raw('SUM(other_service_report_to_products.quantity) as total_quantity'))
                    ->join('other_service_report_to_products','other_service_reports.id','=','other_service_report_to_products.other_service_report_id')
                    ->where('other_service_reports.cwo_id', $cwo_id)
                    ->where('other_service_reports.status',1)
                    ->whereDate('other_service_reports.date', '=', $date)
                    ->get();
        // echo "<pre>";print_r($totalProductsSold->toArray());exit;
        $totalProductsSold = $totalProductsSold[0]->total_quantity != '' ? $totalProductsSold[0]->total_quantity : 0;  


        $revenueInCashOtherProducts = OtherServiceReport::select(DB::raw('SUM(other_service_reports.total_amount) as total_revenue'))
                    // ->join('cwo_master','cwo_master.id','=','other_service_reports.cwo_id')
                    ->where('other_service_reports.cwo_id', $cwo_id)
                    ->where('other_service_reports.status',1)
                    ->where('other_service_reports.payment_details', 'cash')
                    ->whereDate('other_service_reports.date', '=', $date)
                    ->get();
        // echo "<pre>";print_r($revenueInCashOtherProducts->toArray());exit;
        $revenueInCashOtherProducts = $revenueInCashOtherProducts[0]->total_revenue != '' ? $revenueInCashOtherProducts[0]->total_revenue : 0;   

        $revenueInCardOtherProducts = OtherServiceReport::select(DB::raw('SUM(other_service_reports.total_amount) as total_revenue'))
                    // ->join('cwo_master','cwo_master.id','=','other_service_reports.cwo_id')
                    ->where('other_service_reports.cwo_id', $cwo_id)
                    ->where('other_service_reports.status',1)
                    ->where('other_service_reports.payment_details', 'like', '%' . 'card' . '%')
                    ->whereDate('other_service_reports.date', '=', $date)
                    ->get();
        // echo "<pre>";print_r($revenueInCardOtherProducts->toArray());exit;
        $revenueInCardOtherProducts = $revenueInCardOtherProducts[0]->total_revenue != '' ? $revenueInCardOtherProducts[0]->total_revenue : 0;  

        $revenueInContractOtherProducts = OtherServiceReport::select(DB::raw('SUM(other_service_reports.total_amount) as total_revenue'))
                    ->join('cwo_master','cwo_master.id','=','other_service_reports.cwo_id')
                    ->where('other_service_reports.cwo_id', $cwo_id)
                    ->where('other_service_reports.status',1)
                    ->where('other_service_reports.payment_details', 'like', '%' . 'contract' . '%')
                    ->whereDate('other_service_reports.date', '=', $date)
                    ->get();
        // echo "<pre>";print_r($revenueInContractOtherProducts->toArray());exit;
        $revenueInContractOtherProducts = $revenueInContractOtherProducts[0]->total_revenue != '' ? $revenueInContractOtherProducts[0]->total_revenue : 0;                       
        /***************** other products/services ends *********************/

        $card_data = [
            
            [
                'title' => 'Total # of Cars Washed',
                'count' => $todayTotalCarWashed,
                'icon' => 'icon-credit-card',
                'color' => '#e58e95'
            ],
            [
                'title' => 'Total Cash Payments',
                'count' => $getCurrency . formatCurrency($todayRevenueInCash),
                'icon' => 'icon-credit-card',
                'color' => '#90afd0'
            ],
            [
                'title' => 'Total Card Payments',
                'count' => $getCurrency . formatCurrency($todayRevenueInCard),
                'icon' => 'icon-credit-card',
                'color' => '#df3657'
            ],
            [
                'title' => 'Total by Contract',
                'count' => $getCurrency . formatCurrency($todayRevenueInContract),
                'icon' => 'icon-credit-card',
                'color' => '#1e89c8'
            ],
            [
                'title' => 'Total by EFT',
                'count' => $getCurrency . formatCurrency($todayRevenueInEft),
                'icon' => 'icon-credit-card',
                'color' => '#ffa730'
            ],
            [
                'title' => 'Total # of Products Sold',
                'count' => $totalProductsSold,
                'icon' => 'icon-credit-card',
                'color' => '#ffa730'
            ],
            [
                'title' => 'Other Products Cash Payments',
                'count' => $getCurrency . formatCurrency($revenueInCashOtherProducts),
                'icon' => 'icon-credit-card',
                'color' => '#5dbaac'
            ],
            [
                'title' => 'Other Products Card Payments',
                'count' => $getCurrency . formatCurrency($revenueInCardOtherProducts),
                'icon' => 'icon-credit-card',
                'color' => '#1e89c8'
            ],
            [
                'title' => 'Other Products Contract',
                'count' => $getCurrency . formatCurrency($revenueInContractOtherProducts),
                'icon' => 'icon-credit-card',
                'color' => '#df3657'
            ],
            [
                'title' => 'Other Products EFT',
                'count' => 0,
                'icon' => 'icon-credit-card',
                'color' => '#e58e95'
            ],
        ];

        return $card_data;
    }

    protected function card_data($search_date)
    {
        $cwo_id = Auth::user()->cwo_id;
        $today = date('Y-m-d');
        if($search_date != ''){
            $date = date("Y-m-d", strtotime($search_date));
        } else {
            $date = $today;
        }    
        $getCurrency = getCurencyOfCwo($cwo_id);

        /***************** total car washed starts *********************/ 
        $todayTotalCarWashed = WashDetail::where('cwo_id', $cwo_id)
            ->whereDate('date_washed', '=', $date)
            // ->where('status', 3)
            ->count(); 
        /***************** total car washed ends *********************/ 

        /***************** cash starts *********************/
        $todayRevenueInCash = WashDetail::select(DB::raw('SUM(wash_details.cash_amount) as total_revenue'))
            ->join('cwo_master','cwo_master.id','=','wash_details.cwo_id')
            ->where('wash_details.cwo_id', $cwo_id)
            // ->where('wash_details.payment_details', 'cash')
            ->whereDate('wash_details.date_washed', '=', $date)
            ->where('wash_details.is_deleted', 0)
            ->get();
        // echo "<pre>";print_r($todayRevenueInCash->toArray());exit;
        $todayRevenueInCash = $todayRevenueInCash[0]->total_revenue != '' ? $todayRevenueInCash[0]->total_revenue : 0;
        /***************** cash ends *********************/

        /***************** card starts *********************/
        $todayRevenueInCard = WashDetail::select(DB::raw('SUM(wash_details.card_amount) as total_revenue'))
            ->join('cwo_master','cwo_master.id','=','wash_details.cwo_id')
            ->where('wash_details.cwo_id', $cwo_id)
            // ->where('wash_details.payment_details', 'card')
            // ->where('wash_details.payment_details', 'like', '%' . 'card' . '%')
            ->whereDate('wash_details.date_washed', '=', $date)
            ->where('wash_details.is_deleted', 0)
            ->get();
        // echo "<pre>";print_r($todayRevenueInCard->toArray());exit;
        $todayRevenueInCard = $todayRevenueInCard[0]->total_revenue != '' ? $todayRevenueInCard[0]->total_revenue : 0;
        /***************** card ends *********************/

        /***************** contract starts *********************/
        $todayRevenueInContract = WashDetail::select(DB::raw('SUM(wash_details.total_amount) as total_revenue'))
            ->join('cwo_master','cwo_master.id','=','wash_details.cwo_id')
            ->where('wash_details.cwo_id', $cwo_id)
            ->where('wash_details.payment_details', 'like', '%' . 'contract' . '%')
            ->whereDate('wash_details.date_washed', '=', $date)
            ->where('wash_details.is_deleted', 0)
            ->get();
        // echo "<pre>";print_r($todayRevenueInContract->toArray());exit;
        $todayRevenueInContract = $todayRevenueInContract[0]->total_revenue != '' ? $todayRevenueInContract[0]->total_revenue : 0;

        $todayRevenueInEft = WashDetail::select(DB::raw('SUM(wash_details.total_amount) as total_revenue'))
            ->join('cwo_master','cwo_master.id','=','wash_details.cwo_id')
            ->where('wash_details.cwo_id', $cwo_id)
            ->where('wash_details.payment_details', 'like', '%' . 'eft' . '%')
            ->whereDate('wash_details.date_washed', '=', $date)
            ->where('wash_details.is_deleted', 0)
            ->get();
        // echo "<pre>";print_r($todayRevenueInEft->toArray());exit;
        $todayRevenueInEft = $todayRevenueInEft[0]->total_revenue != '' ? $todayRevenueInEft[0]->total_revenue : 0;

        // $todayRevenueInCash = $todayRevenueInCash + $todayRevenueInContract;
        /******************* contract ends ************************/

        /***************** other products/services starts *********************/
        $totalProductsSold = OtherServiceReport::select(DB::raw('SUM(other_service_report_to_products.quantity) as total_quantity'))
                    ->join('other_service_report_to_products','other_service_reports.id','=','other_service_report_to_products.other_service_report_id')
                    ->where('other_service_reports.cwo_id', $cwo_id)
                    ->where('other_service_reports.status',1)
                    ->whereDate('other_service_reports.date', '=', $date)
                    ->get();
        // echo "<pre>";print_r($totalProductsSold->toArray());exit;
        $totalProductsSold = $totalProductsSold[0]->total_quantity != '' ? $totalProductsSold[0]->total_quantity : 0;  


        $revenueInCashOtherProducts = OtherServiceReport::select(DB::raw('SUM(other_service_reports.cash_amount) as total_revenue'))
                    // ->join('cwo_master','cwo_master.id','=','other_service_reports.cwo_id')
                    ->where('other_service_reports.cwo_id', $cwo_id)
                    ->where('other_service_reports.status',1)
                    // ->where('other_service_reports.payment_details', 'cash')
                    ->whereDate('other_service_reports.date', '=', $date)
                    ->get();
        // echo "<pre>";print_r($revenueInCashOtherProducts->toArray());exit;
        $revenueInCashOtherProducts = $revenueInCashOtherProducts[0]->total_revenue != '' ? $revenueInCashOtherProducts[0]->total_revenue : 0;   

        $revenueInCardOtherProducts = OtherServiceReport::select(DB::raw('SUM(other_service_reports.card_amount) as total_revenue'))
                    // ->join('cwo_master','cwo_master.id','=','other_service_reports.cwo_id')
                    ->where('other_service_reports.cwo_id', $cwo_id)
                    ->where('other_service_reports.status',1)
                    // ->where('other_service_reports.payment_details', 'like', '%' . 'card' . '%')
                    ->whereDate('other_service_reports.date', '=', $date)
                    ->get();
        // echo "<pre>";print_r($revenueInCardOtherProducts->toArray());exit;
        $revenueInCardOtherProducts = $revenueInCardOtherProducts[0]->total_revenue != '' ? $revenueInCardOtherProducts[0]->total_revenue : 0;  

        $revenueInContractOtherProducts = OtherServiceReport::select(DB::raw('SUM(other_service_reports.total_amount) as total_revenue'))
                    ->join('cwo_master','cwo_master.id','=','other_service_reports.cwo_id')
                    ->where('other_service_reports.cwo_id', $cwo_id)
                    ->where('other_service_reports.status',1)
                    ->where('other_service_reports.payment_details', 'like', '%' . 'contract' . '%')
                    ->whereDate('other_service_reports.date', '=', $date)
                    ->get();
        // echo "<pre>";print_r($revenueInContractOtherProducts->toArray());exit;
        $revenueInContractOtherProducts = $revenueInContractOtherProducts[0]->total_revenue != '' ? $revenueInContractOtherProducts[0]->total_revenue : 0; 

        $revenueInEftOtherProducts = OtherServiceReport::select(DB::raw('SUM(other_service_reports.total_amount) as total_revenue'))
                    ->join('cwo_master','cwo_master.id','=','other_service_reports.cwo_id')
                    ->where('other_service_reports.cwo_id', $cwo_id)
                    ->where('other_service_reports.status',1)
                    ->where('other_service_reports.payment_details', 'like', '%' . 'eft' . '%')
                    ->whereDate('other_service_reports.date', '=', $date)
                    ->get();
        // echo "<pre>";print_r($revenueInEftOtherProducts->toArray());exit;
        $revenueInEftOtherProducts = $revenueInEftOtherProducts[0]->total_revenue != '' ? $revenueInEftOtherProducts[0]->total_revenue : 0;                      
        /***************** other products/services ends *********************/

        $card_data = [
            
            [
                'title' => 'Total # of Cars Washed',
                'count' => $todayTotalCarWashed,
                'icon' => 'icon-credit-card',
                'color' => '#e58e95'
            ],
            [
                'title' => 'Total Cash Payments',
                'count' => $getCurrency . formatCurrency($todayRevenueInCash),
                'icon' => 'icon-credit-card',
                'color' => '#90afd0'
            ],
            [
                'title' => 'Total Card Payments',
                'count' => $getCurrency . formatCurrency($todayRevenueInCard),
                'icon' => 'icon-credit-card',
                'color' => '#df3657'
            ],
            [
                'title' => 'Total by Contract',
                'count' => $getCurrency . formatCurrency($todayRevenueInContract),
                'icon' => 'icon-credit-card',
                'color' => '#1e89c8'
            ],
            [
                'title' => 'Total by EFT',
                'count' => $getCurrency . formatCurrency($todayRevenueInEft),
                'icon' => 'icon-credit-card',
                'color' => '#ffa730'
            ],
            [
                'title' => 'Total # of Products Sold',
                'count' => $totalProductsSold,
                'icon' => 'icon-credit-card',
                'color' => '#ffa730'
            ],
            [
                'title' => 'Other Products Cash Payments',
                'count' => $getCurrency . formatCurrency($revenueInCashOtherProducts),
                'icon' => 'icon-credit-card',
                'color' => '#5dbaac'
            ],
            [
                'title' => 'Other Products Card Payments',
                'count' => $getCurrency . formatCurrency($revenueInCardOtherProducts),
                'icon' => 'icon-credit-card',
                'color' => '#1e89c8'
            ],
            [
                'title' => 'Other Products Contract',
                'count' => $getCurrency . formatCurrency($revenueInContractOtherProducts),
                'icon' => 'icon-credit-card',
                'color' => '#df3657'
            ],
            [
                'title' => 'Other Products EFT',
                'count' => $getCurrency . formatCurrency($revenueInEftOtherProducts),
                'icon' => 'icon-credit-card',
                'color' => '#e58e95'
            ],
        ];

        return $card_data;
    }
}
