e353f425 by G Manojkumar

Added Supervisor view and minor changes

1 parent 06075955
......@@ -61,10 +61,11 @@ class OutputReportController extends Controller
)
);
$outputReport->user_id = Auth::user()->id;
$outputReport->user_name = Auth::user()->username;
$outputReport->date = date("Y-m-d");
$outputReport->call_attempts = $request->input('noOfAttempts');
$outputReport->call_contacts = $request->input('noOfContacts');
$outputReport->call_unique_contacts =$request->input('uniqueContacts');
$outputReport->call_unique_contacts = $request->input('uniqueContacts');
// $totalIncome = $totalIncome + ($value['lc'] * $value['lcAmt']);
if($value['lc'] != '' && $value['lcAmt'] != ''){
......@@ -93,7 +94,10 @@ class OutputReportController extends Controller
public function show($id)
{
if($id=="reportdata")
{
{
$dashboarduser=Auth::user();
//if($dashboarduser->usertype == "User"){
// output reports
$products = DB::table('output_products')
->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
$totalIncome = DB::select("select sum(income) as income from output_report where user_id=".Auth::user()->id);
// noOfAttempts
$noOfAttempts = CRMCall::where('userstatus','!=','InboundDROP')->where('created_at','>',date('Y-m-d',time()))->where('user_id','=',Auth::user()->id)->count();
$noOfContacts = CRMCall::where('userstatus','NOT IN',"('NORECORD','InboundDROP')")->where('created_at','>',date('Y-m-d',time()))->where('user_id','=',Auth::user()->id)->count();
$uniqueContacts = DB::select("select count(distinct(number)) as uniquecount from crmcalls where userstatus NOT IN ('InboundDROP','NORECORD') and user_id=".Auth::user()->id);
return view("layout.module.outputreport.outputreport")->with('data', ['products' => $products, 'totalIncome' => $totalIncome[0]->income, 'noOfAttempts' => $noOfAttempts , 'noOfContacts' => $noOfContacts , 'uniqueContacts' => $uniqueContacts]);
$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');
//print_r($uniqueContacts);
//if($dashboarduser->usertype == "User"){
$noOfAttempts = $noOfAttempts->where('user_id','=',$dashboarduser->id)->count();
$noOfContacts = $noOfContacts->where('user_id','=',$dashboarduser->id)->count();
$uniqueContacts =$uniqueContacts->where('user_id','=',$dashboarduser->id)->get();
//print_r($uniqueContacts[0]->total);
//$uniqueContacts = $uniqueContacts[0]->total;
$j=0;
foreach($uniqueContacts as $unique){
$j++;
}
$uniqueContacts=$j;
//echo $uniqueContacts;
$supervisor = User::where('supervisor','=',Auth::user()->username)->get();
$usersarray= array();
foreach($supervisor as $users){
$usersarray[] = $users->id;
}
//print_r($usersarray);
$output = DB::table('output_report')->whereIn('user_id',$usersarray)->where('date','=',date("Y-m-d"))->orderBy('user_id')->get();
return view("layout.module.outputreport.outputreport")->with('data', ['products' => $products, 'totalIncome' => $totalIncome[0]->income, 'noOfAttempts' => $noOfAttempts , 'noOfContacts' => $noOfContacts , 'uniqueContacts' => $uniqueContacts , 'output' => $output]);
// }
}
return view("layout.module.outputreport.$id",array());
......
<?php
use App\Models\User;
if(Auth::user()->id=="1" || Auth::user()->id=="90" || Auth::user()->id == "127"){ ?>
<div class="container">
<div style="text-align:center">
<h2>Output Report</h2>
......@@ -6,9 +10,10 @@
<div class="row">
<div class="column">
<?php if(Auth::user()->usertype == "User"){ ?>
<form class="form-horizontal" id="output-report" name="output-report">
<div class="table-responsive" style="background: #fff;">
<table class="table">
<thead>
<tr>
......@@ -25,14 +30,16 @@
</tr>
<tr>
<th>Unique Contacts</th>
<th><?php $data['uniqueContacts'] ?>
<input type="hidden" name="uniqueContacts" value="<?php $data['uniqueContacts'] ?>">
<th><?php echo $data['uniqueContacts']; ?>
<input type="hidden" name="uniqueContacts" value="<?php echo $data['uniqueContacts']; ?>">
</th>
</tr>
<tr>
<th>Income Achievement</th>
<th><?php echo $data['totalIncome']; ?></th>
</tr>
<tr>
<th>Product</th>
<th>LG</th>
......@@ -67,10 +74,50 @@
<td><button type="submit" class="btn btn-primary" onclick='createOutputReport();return false;'>Save</button></td></tr>
</tbody>
</table>
</div>
</form>
<?php }
if(Auth::user()->usertype == "Supervisor"){ ?>
<form class="form-horizontal" id="output-report-supervisor" name="output-report-supervisor">
<div class="table-responsive" style="background: #fff;">
<table class="table">
<thead>
<th></th>
<th>Username</th>
<!--<th>Date</th>-->
<th>Call Attempts</th>
<th>Call Contacts</th>
<th>Call Unique Contacts</th>
<th>Income</th>
<th>Product Name</th>
<th>Lead Generated</th>
<th>Lead Generated Amount</th>
<th>Lead Closed</th>
<th>Lead Closed Amount</th>
</thead>
<?php
$i=1;
foreach($data['output'] as $key => $value){
//print_r($value);
?>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $value->user_name;?></td>
<td><?php echo $value->call_attempts;?></td>
<td><?php echo $value->call_contacts;?></td>
<td><?php echo $value->call_unique_contacts;?></td>
<td><?php echo $value->income;?></td>
<td><?php echo $value->product_name;?></td>
<td><?php echo $value->lead_generated;?></td>
<td><?php echo $value->lead_generated_amount;?></td>
<td><?php echo $value->lead_closed;?></td>
<td><?php echo $value->lead_closed_amount;?></td>
</tr>
<?php $i++; } ?>
</table>
</div>
</form>
<?php } ?>
<script>
function createOutputReport()
......@@ -97,3 +144,4 @@ function createOutputReport()
</div>
</div>
</div>
<?php } ?>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!