required doAjax
Showing
2 changed files
with
37 additions
and
21 deletions
| ... | @@ -96,7 +96,7 @@ class OutputReportController extends Controller | ... | @@ -96,7 +96,7 @@ class OutputReportController extends Controller |
| 96 | { | 96 | { |
| 97 | if($id=="reportdata") | 97 | if($id=="reportdata") |
| 98 | { | 98 | { |
| 99 | echo $id; | 99 | //echo $id; |
| 100 | $data = array(); | 100 | $data = array(); |
| 101 | $disabled = ""; | 101 | $disabled = ""; |
| 102 | $dashboarduser=Auth::user(); | 102 | $dashboarduser=Auth::user(); |
| ... | @@ -113,7 +113,7 @@ class OutputReportController extends Controller | ... | @@ -113,7 +113,7 @@ class OutputReportController extends Controller |
| 113 | ->get(); | 113 | ->get(); |
| 114 | $report = DB::table('output_report') | 114 | $report = DB::table('output_report') |
| 115 | ->where('user_id',Auth::user()->id) | 115 | ->where('user_id',Auth::user()->id) |
| 116 | // ->where('date',DATE("Y-m-d",time())) | 116 | ->where('date',DATE("Y-m-d",time())) |
| 117 | ->get(); | 117 | ->get(); |
| 118 | 118 | ||
| 119 | 119 | ||
| ... | @@ -145,46 +145,54 @@ class OutputReportController extends Controller | ... | @@ -145,46 +145,54 @@ class OutputReportController extends Controller |
| 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('number',DB::raw('count(*) as total'))->whereIn('usersubstatus',["Contacted","Feedback"])->where('created_at','>',date('Y-m-d',time()))->groupBy('number'); |
| 147 | //print_r($uniqueContacts); | 147 | //print_r($uniqueContacts); |
| 148 | //if($dashboarduser->usertype == "User"){ | ||
| 149 | $noOfAttempts = $noOfAttempts->where('user_id','=',$dashboarduser->id)->count(); | 148 | $noOfAttempts = $noOfAttempts->where('user_id','=',$dashboarduser->id)->count(); |
| 150 | $noOfContacts = $noOfContacts->where('user_id','=',$dashboarduser->id)->count(); | 149 | $noOfContacts = $noOfContacts->where('user_id','=',$dashboarduser->id)->count(); |
| 151 | $uniqueContacts =$uniqueContacts->where('user_id','=',$dashboarduser->id)->get(); | 150 | $uniqueContacts =$uniqueContacts->where('user_id','=',$dashboarduser->id)->get(); |
| 152 | //print_r($uniqueContacts[0]->total); | ||
| 153 | //$uniqueContacts = $uniqueContacts[0]->total; | ||
| 154 | $j=0; | 151 | $j=0; |
| 155 | foreach($uniqueContacts as $unique){ | 152 | foreach($uniqueContacts as $unique){ |
| 156 | $j++; | 153 | $j++; |
| 157 | } | 154 | } |
| 158 | $uniqueContacts=$j; | 155 | $uniqueContacts=$j; |
| 159 | //echo $uniqueContacts; | 156 | //echo $uniqueContacts; |
| 160 | $supervisor = User::where('supervisor','=',Auth::user()->username)->get(); | ||
| 161 | $usersarray= array(); | ||
| 162 | foreach($supervisor as $users){ | ||
| 163 | $usersarray[] = $users->id; | ||
| 164 | } | ||
| 165 | //print_r($usersarray); | 157 | //print_r($usersarray); |
| 166 | $output = DB::table('output_report')->whereIn('user_id',$usersarray)->where('date','=',date("Y-m-d"))->orderBy('user_id')->get(); | ||
| 167 | print_r($noOfAttempts); | ||
| 168 | $data['disabled'] = $disabled; | 158 | $data['disabled'] = $disabled; |
| 169 | $data['products'] = $outputReport; | 159 | $data['products'] = $outputReport; |
| 170 | $data['totalIncome'] = $totalIncome[0]->income; | 160 | $data['totalIncome'] = $totalIncome[0]->income; |
| 171 | $data['noOfAttempts'] = $noOfAttempts; | 161 | $data['noOfAttempts'] = $noOfAttempts; |
| 172 | $data['noOfContacts'] = $noOfContacts; | 162 | $data['noOfContacts'] = $noOfContacts; |
| 173 | $data['uniqueContacts'] = $uniqueContacts; | 163 | $data['uniqueContacts'] = $uniqueContacts; |
| 174 | $data['output'] = $output; | ||
| 175 | $data['report'] = $report; | ||
| 176 | 164 | ||
| 177 | return view("layout.module.outputreport.outputreport", $data); | 165 | return view("layout.module.outputreport.outputreport", $data); |
| 178 | // } | 166 | // } |
| 179 | } | 167 | } |
| 180 | if($id == "supervisordata"){ | 168 | if($id == "supervisordata"){ |
| 169 | //$user=Input::get('supervisor'); | ||
| 170 | //echo $user; | ||
| 171 | //if($user=="user"){ | ||
| 172 | $users=Input::get("user"); | ||
| 173 | //echo "Came".$user; | ||
| 174 | |||
| 175 | //} | ||
| 176 | if($users == ""){ | ||
| 177 | $users = "ALL"; | ||
| 178 | } | ||
| 179 | //($user)?$user:"ALL"; | ||
| 180 | echo $users; | ||
| 181 | //if($user!="ALL"){ | ||
| 182 | //echo isset($_GET['user'])?$_GET['user']:"All"; | ||
| 181 | $supervisor = User::where('supervisor','=',Auth::user()->username)->get(); | 183 | $supervisor = User::where('supervisor','=',Auth::user()->username)->get(); |
| 182 | //if dropdown value is All then use the below foreach othewise just put the user_id in array based on dropdown | 184 | //if dropdown value is All then use the below foreach othewise just put the user_id in array based on dropdown |
| 183 | $usersarray= array(); | 185 | $usersarray= array(); |
| 184 | foreach($supervisor as $users){ | 186 | if($users=="ALL"){ |
| 185 | $usersarray[] = $users->id; | 187 | foreach($supervisor as $usersval){ |
| 188 | $usersarray[] = $usersval->id; | ||
| 186 | } | 189 | } |
| 187 | //print_r($usersarray); | 190 | } else{ |
| 191 | $usersarray[] = $users; | ||
| 192 | echo $users; | ||
| 193 | print_r($usersarray); | ||
| 194 | } | ||
| 195 | print_r($usersarray); | ||
| 188 | $totalIncome = DB::select("select sum(income) as income from output_report where user_id IN (".implode(',',$usersarray).")"); | 196 | $totalIncome = DB::select("select sum(income) as income from output_report where user_id IN (".implode(',',$usersarray).")"); |
| 189 | $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; "); | 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; "); |
| 190 | $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"); | 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"); |
| ... | @@ -193,7 +201,10 @@ print_r($noOfAttempts); | ... | @@ -193,7 +201,10 @@ print_r($noOfAttempts); |
| 193 | $data['Contacts'] = $Contacts[0]; | 201 | $data['Contacts'] = $Contacts[0]; |
| 194 | $data['totalIncome'] = $totalIncome[0]->income; | 202 | $data['totalIncome'] = $totalIncome[0]->income; |
| 195 | $data['report'] = $report; | 203 | $data['report'] = $report; |
| 204 | $data['users'] = $users; | ||
| 205 | |||
| 196 | return view("layout.module.outputreport.supervisorreport", $data); | 206 | return view("layout.module.outputreport.supervisorreport", $data); |
| 207 | |||
| 197 | } | 208 | } |
| 198 | 209 | ||
| 199 | return view("layout.module.outputreport.$id",array()); | 210 | return view("layout.module.outputreport.$id",array()); | ... | ... |
| ... | @@ -8,11 +8,13 @@ | ... | @@ -8,11 +8,13 @@ |
| 8 | User Id | 8 | User Id |
| 9 | </label> | 9 | </label> |
| 10 | <select id="supervisorid" style="border:1px solid #efefef;" onchange='userchange("");'> | 10 | <select id="supervisorid" style="border:1px solid #efefef;" onchange='userchange("");'> |
| 11 | <option>ALL | 11 | <option value="ALL">ALL |
| 12 | </option> | 12 | </option> |
| 13 | <?php | 13 | <?php |
| 14 | foreach($supervisor as $user){ ?> | 14 | foreach($supervisor as $user){ |
| 15 | <option value="{{$user->id }}">{{$user->username}}</option> | 15 | $selected = ($user->id == $users)?"selected":""; |
| 16 | ?> | ||
| 17 | <option value="{{$user->id }}" {{$selected}}>{{$user->username}}</option> | ||
| 16 | <?php } ?> | 18 | <?php } ?> |
| 17 | </select> | 19 | </select> |
| 18 | <div class="row"> | 20 | <div class="row"> |
| ... | @@ -69,8 +71,11 @@ User Id | ... | @@ -69,8 +71,11 @@ User Id |
| 69 | function userchange() | 71 | function userchange() |
| 70 | { | 72 | { |
| 71 | 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'); | ||
| 72 | //console.log(user); | 77 | //console.log(user); |
| 73 | } | 78 | }); |
| 74 | </script> | 79 | </script> |
| 75 | </div> | 80 | </div> |
| 76 | </div> | 81 | </div> | ... | ... |
-
Please register or sign in to post a comment