c92ad136 by G Manojkumar

After fixed issues of Supervisorreport

1 parent d8f8a11b
......@@ -136,50 +136,34 @@ class OutputReportController extends Controller
}
// total income
$totalIncome = DB::select("select sum(income) as income from output_report where user_id=".Auth::user()->id);
$totalIncome = DB::select("select sum(income) as income from output_report where user_id=".Auth::user()->id." and date='".date('Y-m-d',time())."'");
// noOfAttempts
$noOfAttempts = CRMCall::where('userstatus','!=','InboundDROP')->where('created_at','>',date('Y-m-d',time()));
$noOfContacts = CRMCall::whereIn('usersubstatus',["Contacted","Feedback"])->where('created_at','>',date('Y-m-d',time()));
$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()));
//print_r($uniqueContacts);
$noOfAttempts = $noOfAttempts->where('user_id','=',$dashboarduser->id)->count();
$noOfContacts = $noOfContacts->where('user_id','=',$dashboarduser->id)->count();
$uniqueContacts =$uniqueContacts->where('user_id','=',$dashboarduser->id)->get();
$j=0;
foreach($uniqueContacts as $unique){
$j++;
}
$uniqueContacts=$j;
//echo $uniqueContacts;
//print_r($usersarray);
$data['disabled'] = $disabled;
$data['products'] = $outputReport;
$data['totalIncome'] = $totalIncome[0]->income;
$data['noOfAttempts'] = $noOfAttempts;
$data['noOfContacts'] = $noOfContacts;
$data['uniqueContacts'] = $uniqueContacts;
$data['uniqueContacts'] = $uniqueContacts[0]->total;
return view("layout.module.outputreport.outputreport", $data);
// }
}
if($id == "supervisordata"){
//$user=Input::get('supervisor');
//echo $user;
//if($user=="user"){
$users=Input::get("user");
//echo "Came".$user;
//}
if($users == ""){
$users = "ALL";
}
//($user)?$user:"ALL";
echo $users;
//if($user!="ALL"){
//echo isset($_GET['user'])?$_GET['user']:"All";
$supervisor = User::where('supervisor','=',Auth::user()->username)->get();
//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");
//print_r($report);
$data['supervisor'] = $supervisor;
......
......@@ -37,7 +37,7 @@ User Id
<tr>
<th>Unique Contacts</th>
<th> {{ $Contacts->unique_contacts }}
<th> {{ $Contacts->call_unique_contacts }}
</th>
</tr>
<tr>
......@@ -71,11 +71,11 @@ User Id
function userchange()
{
var user = $('#supervisorid').val();
doAjax('outputreport/supervisordata','user='+user,'_table-responsive__div__','ajax_create_supervisor_report','singlethis','GET',function(retstr)
{
menuAction('outputreport/supervisordata');
//console.log(user);
doAjax('outputreport/supervisordata?user='+user,'','middlemainreportdiv','ajax_create_supervisor_report','singlethis','GET', function(retstr){
menuAction('outputreport/supervisordata?user='+user);
});
}
</script>
</div>
</div>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!