displayLegend(true); $to = Carbon::createFromFormat('Y-m-d H:s:i', $conds['to']); $from = Carbon::createFromFormat('Y-m-d H:s:i', $conds['from']); $period = CarbonPeriod::create($from, $to); $daysCount = $to->diffInDays($from); $dates = []; $inbounds = []; $noAnswers = []; $outbounds = []; foreach ($period as $date) { $inbound = Call:: // select(\DB::raw('count(*) as count'))-> where('owned_by_id', $agent_id) // ->whereBetween('call_date', [$from, $to]) ->whereIn('direction_id', ['1', '3']) ->whereDate('call_date', '=', date($date->format('Y-m-d'))) // ->groupBy(\DB::raw("DATE_FORMAT(call_date, '%d-%m-%Y')")) ->count(); $outbound = Call:: // select(\DB::raw('count(*) as count'))-> where('owned_by_id', $agent_id) // ->whereBetween('call_date', [$from, $to]) ->whereIn('direction_id', ['2', '4']) ->whereDate('call_date', '=', date($date->format('Y-m-d'))) // ->groupBy(\DB::raw("DATE_FORMAT(call_date, '%d-%m-%Y')")) ->count(); $noAnswer = \DB::table('asteriskcdrdb.cdr') ->where('dst', $agent_id) ->where('disposition', 'NO ANSWER') ->where('duration', '!=', '0') ->where('billsec', '0') ->where('lastapp', 'Dial') ->where('dcontext', 'from-queue-exten-only') ->whereDate('calldate', '=', date($date->format('Y-m-d'))) ->count(); // $inbounds[] = $inbound; $inbounds[] = $inbound; $outbounds[] = $outbound; $noAnswers[] = $noAnswer; $dates[] = $date->format('d-M'); } $labels = $dates; // // foreach ($values as $v){ // // $labels[] = $v->yearMonth; // // $income[] = $v->income; // // $expense[] = $v->expense; // // } // // $labels = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20']; // $Inbound = [10, 20, 21, 52, 81, 52, 21, 52, 52, 82, 72, 92]; // $Outbound = [21, 52, 52, 20, 52, 82, 72, 92, 81, 52, 21]; $this->labels($labels); $this->dataset('Inbound', 'bar', $inbounds)->color('#ffffff')->backgroundColor('#2196F3'); $this->dataset('NO ANSWER', 'bar', $noAnswers)->color('#ffffff')->backgroundColor('#EB3170'); $this->dataset('Outbound', 'bar', $outbounds)->color('#ffffff')->backgroundColor('#ffa21a'); } }