After fixed issues of Supervisorreport
Showing
2 changed files
with
13 additions
and
27 deletions
| ... | @@ -136,50 +136,34 @@ class OutputReportController extends Controller | ... | @@ -136,50 +136,34 @@ class OutputReportController extends Controller |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | // total income | 138 | // total income |
| 139 | $totalIncome = DB::select("select sum(income) as income from output_report where user_id=".Auth::user()->id); | 139 | $totalIncome = DB::select("select sum(income) as income from output_report where user_id=".Auth::user()->id." and date='".date('Y-m-d',time())."'"); |
| 140 | 140 | ||
| 141 | // noOfAttempts | 141 | // noOfAttempts |
| 142 | $noOfAttempts = CRMCall::where('userstatus','!=','InboundDROP')->where('created_at','>',date('Y-m-d',time())); | 142 | $noOfAttempts = CRMCall::where('userstatus','!=','InboundDROP')->where('created_at','>',date('Y-m-d',time())); |
| 143 | 143 | ||
| 144 | $noOfContacts = CRMCall::whereIn('usersubstatus',["Contacted","Feedback"])->where('created_at','>',date('Y-m-d',time())); | 144 | $noOfContacts = CRMCall::whereIn('usersubstatus',["Contacted","Feedback"])->where('created_at','>',date('Y-m-d',time())); |
| 145 | 145 | ||
| 146 | $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'); | 146 | $uniqueContacts = DB::table('crmcalls')->select(DB::raw('count(distinct(number)) as total'))->whereIn('usersubstatus',["Contacted","Feedback"])->where('created_at','>',date('Y-m-d',time())); |
| 147 | //print_r($uniqueContacts); | 147 | //print_r($uniqueContacts); |
| 148 | $noOfAttempts = $noOfAttempts->where('user_id','=',$dashboarduser->id)->count(); | 148 | $noOfAttempts = $noOfAttempts->where('user_id','=',$dashboarduser->id)->count(); |
| 149 | $noOfContacts = $noOfContacts->where('user_id','=',$dashboarduser->id)->count(); | 149 | $noOfContacts = $noOfContacts->where('user_id','=',$dashboarduser->id)->count(); |
| 150 | $uniqueContacts =$uniqueContacts->where('user_id','=',$dashboarduser->id)->get(); | 150 | $uniqueContacts =$uniqueContacts->where('user_id','=',$dashboarduser->id)->get(); |
| 151 | $j=0; | ||
| 152 | foreach($uniqueContacts as $unique){ | ||
| 153 | $j++; | ||
| 154 | } | ||
| 155 | $uniqueContacts=$j; | ||
| 156 | //echo $uniqueContacts; | ||
| 157 | //print_r($usersarray); | ||
| 158 | $data['disabled'] = $disabled; | 151 | $data['disabled'] = $disabled; |
| 159 | $data['products'] = $outputReport; | 152 | $data['products'] = $outputReport; |
| 160 | $data['totalIncome'] = $totalIncome[0]->income; | 153 | $data['totalIncome'] = $totalIncome[0]->income; |
| 161 | $data['noOfAttempts'] = $noOfAttempts; | 154 | $data['noOfAttempts'] = $noOfAttempts; |
| 162 | $data['noOfContacts'] = $noOfContacts; | 155 | $data['noOfContacts'] = $noOfContacts; |
| 163 | $data['uniqueContacts'] = $uniqueContacts; | 156 | $data['uniqueContacts'] = $uniqueContacts[0]->total; |
| 164 | 157 | ||
| 165 | return view("layout.module.outputreport.outputreport", $data); | 158 | return view("layout.module.outputreport.outputreport", $data); |
| 166 | // } | 159 | // } |
| 167 | } | 160 | } |
| 168 | if($id == "supervisordata"){ | 161 | if($id == "supervisordata"){ |
| 169 | //$user=Input::get('supervisor'); | ||
| 170 | //echo $user; | ||
| 171 | //if($user=="user"){ | ||
| 172 | $users=Input::get("user"); | 162 | $users=Input::get("user"); |
| 173 | //echo "Came".$user; | ||
| 174 | 163 | ||
| 175 | //} | ||
| 176 | if($users == ""){ | 164 | if($users == ""){ |
| 177 | $users = "ALL"; | 165 | $users = "ALL"; |
| 178 | } | 166 | } |
| 179 | //($user)?$user:"ALL"; | ||
| 180 | echo $users; | ||
| 181 | //if($user!="ALL"){ | ||
| 182 | //echo isset($_GET['user'])?$_GET['user']:"All"; | ||
| 183 | $supervisor = User::where('supervisor','=',Auth::user()->username)->get(); | 167 | $supervisor = User::where('supervisor','=',Auth::user()->username)->get(); |
| 184 | //if dropdown value is All then use the below foreach othewise just put the user_id in array based on dropdown | 168 | //if dropdown value is All then use the below foreach othewise just put the user_id in array based on dropdown |
| 185 | $usersarray= array(); | 169 | $usersarray= array(); |
| ... | @@ -189,12 +173,14 @@ class OutputReportController extends Controller | ... | @@ -189,12 +173,14 @@ class OutputReportController extends Controller |
| 189 | } | 173 | } |
| 190 | } else{ | 174 | } else{ |
| 191 | $usersarray[] = $users; | 175 | $usersarray[] = $users; |
| 192 | echo $users; | ||
| 193 | print_r($usersarray); | ||
| 194 | } | 176 | } |
| 195 | print_r($usersarray); | ||
| 196 | $totalIncome = DB::select("select sum(income) as income from output_report where user_id IN (".implode(',',$usersarray).")"); | 177 | $totalIncome = DB::select("select sum(income) as income from output_report where user_id IN (".implode(',',$usersarray).")"); |
| 197 | $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; "); | 178 | $Contacts = DB::select("Select Count(user_id), Sum(call_attempts) as call_attempts, |
| 179 | Sum(call_contacts) as call_contacts, | ||
| 180 | Sum(call_unique_contacts) as call_unique_contacts | ||
| 181 | From (Select Distinct user_id, call_attempts, call_contacts, call_unique_contacts From output_report) a | ||
| 182 | where user_id in (".implode(',',$usersarray).") | ||
| 183 | "); | ||
| 198 | $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"); | 184 | $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"); |
| 199 | //print_r($report); | 185 | //print_r($report); |
| 200 | $data['supervisor'] = $supervisor; | 186 | $data['supervisor'] = $supervisor; | ... | ... |
| ... | @@ -37,7 +37,7 @@ User Id | ... | @@ -37,7 +37,7 @@ User Id |
| 37 | <tr> | 37 | <tr> |
| 38 | <th>Unique Contacts</th> | 38 | <th>Unique Contacts</th> |
| 39 | 39 | ||
| 40 | <th> {{ $Contacts->unique_contacts }} | 40 | <th> {{ $Contacts->call_unique_contacts }} |
| 41 | </th> | 41 | </th> |
| 42 | </tr> | 42 | </tr> |
| 43 | <tr> | 43 | <tr> |
| ... | @@ -71,11 +71,11 @@ User Id | ... | @@ -71,11 +71,11 @@ User Id |
| 71 | function userchange() | 71 | function userchange() |
| 72 | { | 72 | { |
| 73 | var user = $('#supervisorid').val(); | 73 | var user = $('#supervisorid').val(); |
| 74 | doAjax('outputreport/supervisordata','user='+user,'_table-responsive__div__','ajax_create_supervisor_report','singlethis','GET',function(retstr) | ||
| 75 | { | ||
| 76 | menuAction('outputreport/supervisordata'); | ||
| 77 | //console.log(user); | 74 | //console.log(user); |
| 75 | doAjax('outputreport/supervisordata?user='+user,'','middlemainreportdiv','ajax_create_supervisor_report','singlethis','GET', function(retstr){ | ||
| 76 | menuAction('outputreport/supervisordata?user='+user); | ||
| 78 | }); | 77 | }); |
| 78 | } | ||
| 79 | </script> | 79 | </script> |
| 80 | </div> | 80 | </div> |
| 81 | </div> | 81 | </div> | ... | ... |
-
Please register or sign in to post a comment