87c06fcf by prami

store and fetch output report

1 parent 0d07fdc6
...@@ -2,12 +2,21 @@ ...@@ -2,12 +2,21 @@
2 2
3 namespace App\Http\Controllers; 3 namespace App\Http\Controllers;
4 4
5
6 use Auth;
7 use Input;
8 use Response;
9 use Config;
10 use App\Models\OutputReport;
11 use App\Models\OutputProduct;
12 use App\Models\CRMCall;
13 use App\Models\User;
5 use Illuminate\Http\Request; 14 use Illuminate\Http\Request;
6 use Illuminate\Support\Facades\DB; 15 use Illuminate\Support\Facades\DB;
7 16
8 use App\Http\Requests; 17 use App\Http\Requests;
9 18
10 class VirtualController extends Controller 19 class OutputReportController extends Controller
11 { 20 {
12 /** 21 /**
13 * Display a listing of the resource. 22 * Display a listing of the resource.
...@@ -24,9 +33,9 @@ class VirtualController extends Controller ...@@ -24,9 +33,9 @@ class VirtualController extends Controller
24 * 33 *
25 * @return \Illuminate\Http\Response 34 * @return \Illuminate\Http\Response
26 */ 35 */
27 public function create() 36 public function createOutputReport()
28 { 37 {
29 // 38
30 } 39 }
31 40
32 /** 41 /**
...@@ -37,7 +46,42 @@ class VirtualController extends Controller ...@@ -37,7 +46,42 @@ class VirtualController extends Controller
37 */ 46 */
38 public function store(Request $request) 47 public function store(Request $request)
39 { 48 {
40 // 49 $action=Input::get('action');
50 //echo $action;
51 if($action=="createOutputReport"){
52
53 $products = $request->input('products');
54 //print_r($products);
55 //$totalIncome = 0;
56 foreach ($products as $key => $value) {
57
58 $outputReport = OutputReport::firstOrCreate(
59 array(
60 'product_id' => $value['productId']
61 )
62 );
63 $outputReport->user_id = Auth::user()->id;
64 $outputReport->date = date("Y-m-d");
65 $outputReport->call_attempts = $request->input('noOfAttempts');
66 $outputReport->call_contacts = $request->input('noOfContacts');
67 $outputReport->call_unique_contacts =$request->input('uniqueContacts');
68 // $totalIncome = $totalIncome + ($value['lc'] * $value['lcAmt']);
69
70 if($value['lc'] != '' && $value['lcAmt'] != ''){
71 $outputReport->income = $value['lc'] * $value['lcAmt'];
72 }
73 $outputReport->product_name = $value['product'];
74 $outputReport->lead_generated = $value['lg'];
75 $outputReport->lead_generated_amount = $value['lgAmt'];
76 $outputReport->lead_closed = $value['lc'];
77 $outputReport->lead_closed_amount = $value['lcAmt'];
78 $outputReport->created_at = date('Y-m-d H:i:s');
79 $outputReport->updated_at =date('Y-m-d H:i:s');
80 $outputReport->save();
81
82
83 }
84 }
41 } 85 }
42 86
43 /** 87 /**
...@@ -48,13 +92,30 @@ class VirtualController extends Controller ...@@ -48,13 +92,30 @@ class VirtualController extends Controller
48 */ 92 */
49 public function show($id) 93 public function show($id)
50 { 94 {
51 if($id=="Virtualdata") 95 if($id=="reportdata")
52 { 96 {
53 $products = DB::table('output_products')->select('id','name','status')->get(); 97 // output reports
54 return view("layout.module.virtualchannel.Virtualdata")->with('products', $products); 98 $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' )
100 ->leftJoin('output_report', 'output_products.id', '=', 'output_report.product_id')
101 ->where('status', '1')
102 ->orderBy('output_products.id')
103 ->get();
104
105 // total income
106 $totalIncome = DB::select("select sum(income) as income from output_report where user_id=".Auth::user()->id);
107
108 // noOfAttempts
109 $noOfAttempts = CRMCall::where('userstatus','!=','InboundDROP')->where('created_at','>',date('Y-m-d',time()))->where('user_id','=',Auth::user()->id)->count();
110
111 $noOfContacts = CRMCall::where('userstatus','NOT IN',"('NORECORD','InboundDROP')")->where('created_at','>',date('Y-m-d',time()))->where('user_id','=',Auth::user()->id)->count();
112
113 $uniqueContacts = DB::select("select count(distinct(number)) as uniquecount from crmcalls where userstatus NOT IN ('InboundDROP','NORECORD') and user_id=".Auth::user()->id);
114
115 return view("layout.module.outputreport.outputreport")->with('data', ['products' => $products, 'totalIncome' => $totalIncome[0]->income, 'noOfAttempts' => $noOfAttempts , 'noOfContacts' => $noOfContacts , 'uniqueContacts' => $uniqueContacts]);
55 } 116 }
56 117
57 return view("layout.module.virtualchannel.$id",array()); 118 return view("layout.module.outputreport.$id",array());
58 119
59 } 120 }
60 121
......
1 <?php
2
3 namespace App\Models;
4 use Illuminate\Database\Eloquent\Model;
5
6 class OutputProduct extends Model{
7
8 protected $table = 'output_products';
9 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace App\Models;
4 use Illuminate\Database\Eloquent\Model;
5
6 class OutputReport extends Model{
7
8 protected $table = 'output_report';
9
10 protected $fillable = ['user_id', 'user_name', 'date', 'call_attempts', 'call_contacts', 'call_unique_contacts', 'income', 'product_id' , 'product_name', 'lead_generated', 'lead_generated_amount', 'lead_closed', 'lead_closed_amount', 'created_at', 'updated_at'];
11 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 use App\Models\CRMCall;
3 use App\Models\User;
4 use App\Jobs\KHRMSLib;
5
6 $attempts = CRMCall::where('userstatus','!=','InboundDROP')->where('created_at','>',date('Y-m-d',time()))->where('user_id','=',Auth::user()->id)->count();
7 print_r(($attempts));
8
9 $Contacts = CRMCall::where('userstatus','NOT IN',"('NORECORD','InboundDROP')")->where('created_at','>',date('Y-m-d',time()))->where('user_id','=',Auth::user()->id)->count();
10 $uniqueContacts = DB::select("select count(distinct(number)) as uniquecount from crmcalls where userstatus NOT IN ('InboundDROP','NORECORD') and user_id=".Auth::user()->id." group by number");
11
12 /**
13 Output Products
14 **/
15 //$Product = DB::table('output_products')->select('id','name','status')->where('status', '1')->get();
16 //print_r($Product);
17 //print_r($uniqueContacts);
18 //include(resource_path().'/views/layout/module/virtualchannel/VirtualFieldsArray.php');
19 //print_r($Product);
20
21 //echo "<div>Virtual</div>";
22 ?>
23 <div class="container"> 1 <div class="container">
24 <div style="text-align:center"> 2 <div style="text-align:center">
25 <h2>Virtual Channels</h2> 3 <h2>Output Report</h2>
26 <p></p> 4 <p></p>
27 </div> 5 </div>
28 6
29 <div class="row"> 7 <div class="row">
30 <div class="column"> 8 <div class="column">
31 <form class="form-horizontal"> 9 <form class="form-horizontal" id="output-report" name="output-report">
32 <div class="table-responsive" style="background: #fff;"> 10 <div class="table-responsive" style="background: #fff;">
33 11
34 <table class="table"> 12 <table class="table">
35 <thead> 13 <thead>
36 <tr> 14 <tr>
37 <th>No.of Attempts</th> 15 <th>No.of Attempts</th>
38 <th><?php echo $attempts; ?></th> 16 <th><?php echo $data['noOfAttempts']; ?>
17 <input type="hidden" name="noOfAttempts" value="<?php echo $data['noOfAttempts']; ?>">
18 </th>
39 </tr> 19 </tr>
40 <tr> 20 <tr>
41 <th>No.of Contacts</th> 21 <th>No.of Contacts</th>
42 <th><?php echo $Contacts; ?></th> 22 <th><?php echo $data['noOfContacts']; ?>
23 <input type="hidden" name="noOfContacts" value="<?php echo $data['noOfContacts']; ?>">
24 </th>
43 </tr> 25 </tr>
44 <tr> 26 <tr>
45 <th>Unique Contacts</th> 27 <th>Unique Contacts</th>
46 <th><?php foreach($uniqueContacts as $uniquecounts){echo $uniquecounts->uniquecount; } ?></th> 28 <th><?php $data['uniqueContacts'] ?>
29 <input type="hidden" name="uniqueContacts" value="<?php $data['uniqueContacts'] ?>">
30 </th>
47 </tr> 31 </tr>
48 <tr> 32 <tr>
49 <th>Income Achievement</th> 33 <th>Income Achievement</th>
50 <th></th> 34 <th><?php echo $data['totalIncome']; ?></th>
51 </tr> 35 </tr>
52 <tr> 36 <tr>
53 <th>Product</th> 37 <th>Product</th>
...@@ -60,19 +44,23 @@ $uniqueContacts = DB::select("select count(distinct(number)) as uniquecount from ...@@ -60,19 +44,23 @@ $uniqueContacts = DB::select("select count(distinct(number)) as uniquecount from
60 <tbody> 44 <tbody>
61 <?php 45 <?php
62 //include(resource_path().'/views/layout/module/virtualchannel/VirtualFieldsArray.php'); 46 //include(resource_path().'/views/layout/module/virtualchannel/VirtualFieldsArray.php');
63 foreach ($products as $key => $value) { 47 $i=1;
48 foreach ($data['products'] as $key => $value) {
64 //print_r($value); 49 //print_r($value);
65 //print_r($ProductType); 50 //print_r($ProductType);
66 $i=1; 51
67 ?> 52 ?>
68 <tr> 53 <tr>
69 <td><?php echo $value->name; ?></td> 54 <td> <input type="hidden" name="products[<?= $i ?>][productId]" value="<?php echo $value->productId; ?>">
70 <td><input type="number" name="lg[<?php echo $value->name; ?>]"></td> 55 <input type="hidden" name="products[<?= $i ?>][product]" value="<?php echo $value->name; ?>" ><?php echo $value->name; ?></td>
71 <td><input type="text" name="lg-amt[<?php echo $value->name; ?>]"></td> 56 <td><input type="number" name="products[<?= $i ?>][lg]" value="<?php echo $value->lead_generated; ?>"></td>
72 <td><input type="number" name="lc[<?php echo $value->name; ?>]"></td> 57 <td><input type="number" min="0" step="0.01" name="products[<?= $i ?>][lgAmt]" value="<?php echo $value->lead_generated_amount; ?>"></td>
73 <td><input type="text" name="lc-amt[<?php echo $value->name; ?>]"></td> 58 <td><input type="number" name="products[<?= $i ?>][lc]" value="<?php echo $value->lead_closed; ?>"></td>
59 <td><input type="number" min="0" step="0.01" name="products[<?= $i ?>][lcAmt]" value="<?php echo $value->lead_closed_amount; ?>"></td>
74 </tr> 60 </tr>
75 <?php 61 <?php
62
63 $i++;
76 } ?> 64 } ?>
77 65
78 <tr> 66 <tr>
...@@ -87,21 +75,20 @@ $uniqueContacts = DB::select("select count(distinct(number)) as uniquecount from ...@@ -87,21 +75,20 @@ $uniqueContacts = DB::select("select count(distinct(number)) as uniquecount from
87 75
88 function createOutputReport() 76 function createOutputReport()
89 { 77 {
90 var putdata="csrftoken={!!Session::token()!!}"; 78 var putdata = $('#output-report').serialize();
91 putdata+="&lc="+$("#lc").val(); 79 //console.log("--->"+putdata);
92 80 doAjax('outputreport?action=createOutputReport',putdata,'__fake__div__','ajax_create_output_report','singlethis','POST',function(retstr)
93 doAjax('user',putdata,'__fake__div__','ajax_users_create','singlethis','POST',function(retstr) 81 {
94 { 82 if(retstr.responseText.indexOf('Error')<0)
95 if(retstr.responseText.indexOf('Error')<0) 83 {
96 { 84 simpleNotification("success","topRight","User Created Successfully");
97 simpleNotification("success","topRight","User Created Successfully"); 85 menuAction('outputreport/reportdata');
98 doAjax('user/'+retstr.responseText+'/edit','','userformdiv','ajax_users_create','singlethis','GET'); 86 }
99 } 87 else
100 else 88 {
101 { 89 simpleNotification("error","topRight",retstr.responseText);
102 simpleNotification("error","topRight",retstr.responseText); 90 }
103 } 91 });
104 });
105 } 92 }
106 93
107 </script> 94 </script>
......
1 <?php
2 //Here array is Productname=>array(LG,ExpectedAmt,LC,Amount)
3 /*$Product = array('Term'=>array('','','',''),'SmartPay'=> array('' , 'NA', '','NA' ),'BillPay'=>array('','NA','','NA'),'BillPay+SI'=>array('','NA','','NA'),'CC LE'=>array('','NA','','NA'),'CC Upgrade'=>array('','NA','','NA'),'PL10Sec'=>array('','','',''),'Quick Money'=>array('','','',''),'Jaldi5'=>array('','','',''),'GI'=>array('','','',''),'MF'=>array('','','',''),'FD/RD'=>array('','','',''),'LI'=>array('','','',''),'AL'=>array('','','',''),'PL-CRM'=>array('','','',''),'PL-DAP'=>array('','','',''),'HL'=>array('','','',''),'Other Assets'=>array('','','',''),'DEMAT'=>array('','NA','','NA'),'CDL'=>array('','','',''),'CC-Fresh'=>array('','NA','','NA'),'CC-STP'=>array('','NA','','NA'),'CASA'=>array('','NA','','NA'),'PayZapp Registration'=>array('','NA','','NA'));*/
4 ?>
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!