e353f425 by G Manojkumar

Added Supervisor view and minor changes

1 parent 06075955
...@@ -61,10 +61,11 @@ class OutputReportController extends Controller ...@@ -61,10 +61,11 @@ class OutputReportController extends Controller
61 ) 61 )
62 ); 62 );
63 $outputReport->user_id = Auth::user()->id; 63 $outputReport->user_id = Auth::user()->id;
64 $outputReport->user_name = Auth::user()->username;
64 $outputReport->date = date("Y-m-d"); 65 $outputReport->date = date("Y-m-d");
65 $outputReport->call_attempts = $request->input('noOfAttempts'); 66 $outputReport->call_attempts = $request->input('noOfAttempts');
66 $outputReport->call_contacts = $request->input('noOfContacts'); 67 $outputReport->call_contacts = $request->input('noOfContacts');
67 $outputReport->call_unique_contacts =$request->input('uniqueContacts'); 68 $outputReport->call_unique_contacts = $request->input('uniqueContacts');
68 // $totalIncome = $totalIncome + ($value['lc'] * $value['lcAmt']); 69 // $totalIncome = $totalIncome + ($value['lc'] * $value['lcAmt']);
69 70
70 if($value['lc'] != '' && $value['lcAmt'] != ''){ 71 if($value['lc'] != '' && $value['lcAmt'] != ''){
...@@ -94,6 +95,9 @@ class OutputReportController extends Controller ...@@ -94,6 +95,9 @@ class OutputReportController extends Controller
94 { 95 {
95 if($id=="reportdata") 96 if($id=="reportdata")
96 { 97 {
98
99 $dashboarduser=Auth::user();
100 //if($dashboarduser->usertype == "User"){
97 // output reports 101 // output reports
98 $products = DB::table('output_products') 102 $products = DB::table('output_products')
99 ->select('output_products.id as productId','output_products.name','output_products.status', 'output_report.product_id', 'output_report.id as reportId', 'output_report.lead_generated', 'output_report.lead_generated_amount', 'output_report.lead_closed' , 'output_report.lead_closed_amount' ) 103 ->select('output_products.id as productId','output_products.name','output_products.status', 'output_report.product_id', 'output_report.id as reportId', 'output_report.lead_generated', 'output_report.lead_generated_amount', 'output_report.lead_closed' , 'output_report.lead_closed_amount' )
...@@ -106,13 +110,33 @@ class OutputReportController extends Controller ...@@ -106,13 +110,33 @@ class OutputReportController extends Controller
106 $totalIncome = DB::select("select sum(income) as income from output_report where user_id=".Auth::user()->id); 110 $totalIncome = DB::select("select sum(income) as income from output_report where user_id=".Auth::user()->id);
107 111
108 // noOfAttempts 112 // noOfAttempts
109 $noOfAttempts = CRMCall::where('userstatus','!=','InboundDROP')->where('created_at','>',date('Y-m-d',time()))->where('user_id','=',Auth::user()->id)->count(); 113 $noOfAttempts = CRMCall::where('userstatus','!=','InboundDROP')->where('created_at','>',date('Y-m-d',time()));
110 114
111 $noOfContacts = CRMCall::where('userstatus','NOT IN',"('NORECORD','InboundDROP')")->where('created_at','>',date('Y-m-d',time()))->where('user_id','=',Auth::user()->id)->count(); 115 $noOfContacts = CRMCall::whereIn('usersubstatus',["Contacted","Feedback"])->where('created_at','>',date('Y-m-d',time()));
112 116
113 $uniqueContacts = DB::select("select count(distinct(number)) as uniquecount from crmcalls where userstatus NOT IN ('InboundDROP','NORECORD') and user_id=".Auth::user()->id); 117 $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');
114 118 //print_r($uniqueContacts);
115 return view("layout.module.outputreport.outputreport")->with('data', ['products' => $products, 'totalIncome' => $totalIncome[0]->income, 'noOfAttempts' => $noOfAttempts , 'noOfContacts' => $noOfContacts , 'uniqueContacts' => $uniqueContacts]); 119 //if($dashboarduser->usertype == "User"){
120 $noOfAttempts = $noOfAttempts->where('user_id','=',$dashboarduser->id)->count();
121 $noOfContacts = $noOfContacts->where('user_id','=',$dashboarduser->id)->count();
122 $uniqueContacts =$uniqueContacts->where('user_id','=',$dashboarduser->id)->get();
123 //print_r($uniqueContacts[0]->total);
124 //$uniqueContacts = $uniqueContacts[0]->total;
125 $j=0;
126 foreach($uniqueContacts as $unique){
127 $j++;
128 }
129 $uniqueContacts=$j;
130 //echo $uniqueContacts;
131 $supervisor = User::where('supervisor','=',Auth::user()->username)->get();
132 $usersarray= array();
133 foreach($supervisor as $users){
134 $usersarray[] = $users->id;
135 }
136 //print_r($usersarray);
137 $output = DB::table('output_report')->whereIn('user_id',$usersarray)->where('date','=',date("Y-m-d"))->orderBy('user_id')->get();
138 return view("layout.module.outputreport.outputreport")->with('data', ['products' => $products, 'totalIncome' => $totalIncome[0]->income, 'noOfAttempts' => $noOfAttempts , 'noOfContacts' => $noOfContacts , 'uniqueContacts' => $uniqueContacts , 'output' => $output]);
139 // }
116 } 140 }
117 141
118 return view("layout.module.outputreport.$id",array()); 142 return view("layout.module.outputreport.$id",array());
......
1
2 <?php
3 use App\Models\User;
4 if(Auth::user()->id=="1" || Auth::user()->id=="90" || Auth::user()->id == "127"){ ?>
1 <div class="container"> 5 <div class="container">
2 <div style="text-align:center"> 6 <div style="text-align:center">
3 <h2>Output Report</h2> 7 <h2>Output Report</h2>
...@@ -6,6 +10,7 @@ ...@@ -6,6 +10,7 @@
6 10
7 <div class="row"> 11 <div class="row">
8 <div class="column"> 12 <div class="column">
13 <?php if(Auth::user()->usertype == "User"){ ?>
9 <form class="form-horizontal" id="output-report" name="output-report"> 14 <form class="form-horizontal" id="output-report" name="output-report">
10 <div class="table-responsive" style="background: #fff;"> 15 <div class="table-responsive" style="background: #fff;">
11 16
...@@ -25,14 +30,16 @@ ...@@ -25,14 +30,16 @@
25 </tr> 30 </tr>
26 <tr> 31 <tr>
27 <th>Unique Contacts</th> 32 <th>Unique Contacts</th>
28 <th><?php $data['uniqueContacts'] ?> 33
29 <input type="hidden" name="uniqueContacts" value="<?php $data['uniqueContacts'] ?>"> 34 <th><?php echo $data['uniqueContacts']; ?>
35 <input type="hidden" name="uniqueContacts" value="<?php echo $data['uniqueContacts']; ?>">
30 </th> 36 </th>
31 </tr> 37 </tr>
32 <tr> 38 <tr>
33 <th>Income Achievement</th> 39 <th>Income Achievement</th>
34 <th><?php echo $data['totalIncome']; ?></th> 40 <th><?php echo $data['totalIncome']; ?></th>
35 </tr> 41 </tr>
42
36 <tr> 43 <tr>
37 <th>Product</th> 44 <th>Product</th>
38 <th>LG</th> 45 <th>LG</th>
...@@ -67,10 +74,50 @@ ...@@ -67,10 +74,50 @@
67 <td><button type="submit" class="btn btn-primary" onclick='createOutputReport();return false;'>Save</button></td></tr> 74 <td><button type="submit" class="btn btn-primary" onclick='createOutputReport();return false;'>Save</button></td></tr>
68 </tbody> 75 </tbody>
69 </table> 76 </table>
70
71 </div> 77 </div>
72 </form> 78 </form>
73 79 <?php }
80 if(Auth::user()->usertype == "Supervisor"){ ?>
81 <form class="form-horizontal" id="output-report-supervisor" name="output-report-supervisor">
82 <div class="table-responsive" style="background: #fff;">
83 <table class="table">
84 <thead>
85 <th></th>
86 <th>Username</th>
87 <!--<th>Date</th>-->
88 <th>Call Attempts</th>
89 <th>Call Contacts</th>
90 <th>Call Unique Contacts</th>
91 <th>Income</th>
92 <th>Product Name</th>
93 <th>Lead Generated</th>
94 <th>Lead Generated Amount</th>
95 <th>Lead Closed</th>
96 <th>Lead Closed Amount</th>
97 </thead>
98 <?php
99 $i=1;
100 foreach($data['output'] as $key => $value){
101 //print_r($value);
102 ?>
103 <tr>
104 <td><?php echo $i; ?></td>
105 <td><?php echo $value->user_name;?></td>
106 <td><?php echo $value->call_attempts;?></td>
107 <td><?php echo $value->call_contacts;?></td>
108 <td><?php echo $value->call_unique_contacts;?></td>
109 <td><?php echo $value->income;?></td>
110 <td><?php echo $value->product_name;?></td>
111 <td><?php echo $value->lead_generated;?></td>
112 <td><?php echo $value->lead_generated_amount;?></td>
113 <td><?php echo $value->lead_closed;?></td>
114 <td><?php echo $value->lead_closed_amount;?></td>
115 </tr>
116 <?php $i++; } ?>
117 </table>
118 </div>
119 </form>
120 <?php } ?>
74 <script> 121 <script>
75 122
76 function createOutputReport() 123 function createOutputReport()
...@@ -97,3 +144,4 @@ function createOutputReport() ...@@ -97,3 +144,4 @@ function createOutputReport()
97 </div> 144 </div>
98 </div> 145 </div>
99 </div> 146 </div>
147 <?php } ?>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!