$uniqueContacts=DB::table('crmcalls')->select('number',DB::raw('count(*) as total'))->whereIn('usersubstatus',["Contacted","Feedback"])->where('created_at','>',date('Y-m-d',time()))->groupBy('number');
$uniqueContacts=DB::table('crmcalls')->select(DB::raw('count(distinct(number)) as total'))->whereIn('usersubstatus',["Contacted","Feedback"])->where('created_at','>',date('Y-m-d',time()));
//if dropdown value is All then use the below foreach othewise just put the user_id in array based on dropdown
$usersarray=array();
...
...
@@ -189,12 +173,14 @@ class OutputReportController extends Controller
}
}else{
$usersarray[]=$users;
echo$users;
print_r($usersarray);
}
print_r($usersarray);
$totalIncome=DB::select("select sum(income) as income from output_report where user_id IN (".implode(',',$usersarray).")");
$Contacts=DB::select("select sum(call_attempts) as call_attempts, sum(call_contacts) as call_contacts, sum(call_unique_contacts) as unique_contacts from output_report where user_id IN (".implode(',',$usersarray).") group by product_id limit 1; ");
$Contacts=DB::select("Select Count(user_id), Sum(call_attempts) as call_attempts,
Sum(call_contacts) as call_contacts,
Sum(call_unique_contacts) as call_unique_contacts
From (Select Distinct user_id, call_attempts, call_contacts, call_unique_contacts From output_report) a
where user_id in (".implode(',',$usersarray).")
");
$report=DB::select("SELECT product_id,product_name, SUM(lead_generated) as totallead, SUM(lead_generated_amount) as totalleadamt, SUM(lead_closed) as totalleadclosed, Sum(lead_closed_amount) as leadcloseamt FROM `output_report` where user_id in (".implode(',',$usersarray).") group by product_id");