4079cd55 by Yashwant

Login report changes

1 parent bb0764be
...@@ -76,7 +76,7 @@ kstychAppObject['config']['colorInverse']='{!!$skinarr[8]!!}'; ...@@ -76,7 +76,7 @@ kstychAppObject['config']['colorInverse']='{!!$skinarr[8]!!}';
76 <script src="{!!url('/')!!}/assets/components/modules/admin/chat/chatboxmanager.js"></script> 76 <script src="{!!url('/')!!}/assets/components/modules/admin/chat/chatboxmanager.js"></script>
77 <script src="{!!url('/')!!}/assets/js/highchart/highcharts.js"></script> 77 <script src="{!!url('/')!!}/assets/js/highchart/highcharts.js"></script>
78 <script> 78 <script>
79 var envCallback = "{{ env(app_domain) }}"; 79 var envCallback = "{{ env('app_domain') }}";
80 </script> 80 </script>
81 <script src="{!!url('/')!!}/jsbody?v={!!$v!!}"></script> 81 <script src="{!!url('/')!!}/jsbody?v={!!$v!!}"></script>
82 82
......
...@@ -15,11 +15,15 @@ $logtime =(isset($_GET['logtime'])) ? $_GET['logtime'] :9; ...@@ -15,11 +15,15 @@ $logtime =(isset($_GET['logtime'])) ? $_GET['logtime'] :9;
15 $logtimeto =(isset($_GET['logtimeto']))? $_GET['logtimeto']:20; 15 $logtimeto =(isset($_GET['logtimeto']))? $_GET['logtimeto']:20;
16 16
17 $logdate =(isset($_GET['logdate'])) ? strtotime($_GET['logdate']." ".$logtime.":00:00") 17 $logdate =(isset($_GET['logdate'])) ? strtotime($_GET['logdate']." ".$logtime.":00:00")
18 : strtotime(date("Y-m-d")." 09:00:00"); 18 : strtotime(date("Y-m-d")." 09:00:00");
19 $logdateto =(isset($_GET['logdateto']))? strtotime($_GET['logdateto']." ".$logtimeto.":00:00") 19 $logdateto =(isset($_GET['logdateto']))? strtotime($_GET['logdateto']." ".$logtimeto.":00:00")
20 : strtotime(date("Y-m-d")." 20:00:00"); 20 : strtotime(date("Y-m-d")." 20:00:00");
21 $campaign =(isset($_GET['campaign'])) ? $_GET['campaign'] : "All"; 21 $campaign =(isset($_GET['campaign'])) ? $_GET['campaign'] : "All";
22 22
23 // testing input
24 // $logtime = 9;$logtimeto = 20;$logdate = strtotime("2017-10-03 ".$logtime.":00:00");$logdateto = strtotime("2017-10-03 ".$logtimeto.":00:00");$campaign = 'All';
25 // testing input
26
23 $alist=CRMCallArchive::where('user_id','!=',0)->where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset)); 27 $alist=CRMCallArchive::where('user_id','!=',0)->where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset));
24 $alist->orderBy('user_id', 'ASC')->orderBy('ts_Close', 'ASC'); 28 $alist->orderBy('user_id', 'ASC')->orderBy('ts_Close', 'ASC');
25 29
...@@ -29,8 +33,8 @@ if($campaign != 'All') $alist->where('client','=',$campaign); ...@@ -29,8 +33,8 @@ if($campaign != 'All') $alist->where('client','=',$campaign);
29 33
30 $userarr=array(); 34 $userarr=array();
31 $allusers = DB::table('users as u1')->leftjoin('users AS u2', 'u2.username', '=', 'u1.supervisor') 35 $allusers = DB::table('users as u1')->leftjoin('users AS u2', 'u2.username', '=', 'u1.supervisor')
32 ->select('u1.id','u1.username','u1.fullname AS telecaller', 'u2.fullname AS sepervisor') 36 ->select('u1.id','u1.username','u1.fullname AS telecaller', 'u2.fullname AS sepervisor')
33 ->where('u1.status','=','Active'); 37 ->where('u1.status','=','Active');
34 38
35 $roclientstr=array();$didlinesstr=array(); 39 $roclientstr=array();$didlinesstr=array();
36 if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten; 40 if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten;
...@@ -45,7 +49,7 @@ if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="") ...@@ -45,7 +49,7 @@ if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
45 } 49 }
46 50
47 $breaks=array("Paused","AgentBriefing","TeamMeeting","QualityFeedback","LunchBreak","TeaBreak","UtilityBreak","FloorAnnouncements","DownTime"); 51 $breaks=array("Paused","AgentBriefing","TeamMeeting","QualityFeedback","LunchBreak","TeaBreak","UtilityBreak","FloorAnnouncements","DownTime");
48 $reporthead=array_merge(array("#","Telecaller","TelecallerID","Supervisor","Signin","Signout","Count","Duration","Total","Wait","Call","Talk","Dispo","P-Call","P-Talk","P-Dispo","M-Call","M-Talk","M-Dispo","I-Call","I-Talk","I-Dispo"),$breaks); 52 $reporthead=array_merge(array("#","Telecaller","TelecallerID","Supervisor","Sessions","CallCount","Duration","Total","Wait","Call","Talk","Dispo","P-Call","P-Talk","P-Dispo","M-Call","M-Talk","M-Dispo","I-Call","I-Talk","I-Dispo"),$breaks);
49 $reportarray=array(); 53 $reportarray=array();
50 54
51 $i=1; 55 $i=1;
...@@ -81,10 +85,14 @@ if($dashboarduser->usertype != 'Admin') ...@@ -81,10 +85,14 @@ if($dashboarduser->usertype != 'Admin')
81 } 85 }
82 } 86 }
83 87
88 // echo "<pre>"; print_r($allusers);exit;
89
84 $alist=$alist->get(); 90 $alist=$alist->get();
85 $userlog=$userlog->get(); 91 $userlog=$userlog->get();
86 $prev_close = 0; 92 $prev_close = 0;
87 93
94 // echo count($userlog);exit;
95
88 foreach($alist as $aline) 96 foreach($alist as $aline)
89 { 97 {
90 if($prev_user != $aline->user_id || $prev_close <= $aline->ts_Wait) 98 if($prev_user != $aline->user_id || $prev_close <= $aline->ts_Wait)
...@@ -121,7 +129,7 @@ foreach($alist as $aline) ...@@ -121,7 +129,7 @@ foreach($alist as $aline)
121 $reportarray[$userid]["I-Dispo"]+=$aline->dispoSec/1000; 129 $reportarray[$userid]["I-Dispo"]+=$aline->dispoSec/1000;
122 } 130 }
123 } 131 }
124 $reportarray[$userid]["Count"]++; 132 $reportarray[$userid]["CallCount"]++;
125 $prev_close = $aline->ts_Close;//-ts_Wait 133 $prev_close = $aline->ts_Close;//-ts_Wait
126 $prev_user = $aline->user_id;//-ts_Wait 134 $prev_user = $aline->user_id;//-ts_Wait
127 } 135 }
...@@ -175,38 +183,56 @@ if(count($userLogin)) foreach ($userLogin as $userid => $value) ...@@ -175,38 +183,56 @@ if(count($userLogin)) foreach ($userLogin as $userid => $value)
175 foreach ($breaks as $break) { 183 foreach ($breaks as $break) {
176 $break_time+=$reportarray[$userid][$break]; 184 $break_time+=$reportarray[$userid][$break];
177 } 185 }
178 $reportarray[$userid]["Signin"]=date("Y-m-d H:i:s", min($value['start'])-$timeoffset); 186 // print_r($value);
179 $reportarray[$userid]["Signout"]=date("Y-m-d H:i:s", max($value['end'])-$timeoffset); 187
188 $sessionsStr = "";
189 for($i = 0; $i < count($value['start']); $i++){
190 if($sessionsStr == ""){
191 $sessionsStr .= date("Y-m-d H:i:s", $value['start'][$i]-$timeoffset)." - ".date("Y-m-d H:i:s", $value['end'][$i]-$timeoffset);
192 }else{
193 $sessionsStr .= ",\n".date("Y-m-d H:i:s", $value['start'][$i]-$timeoffset)." - ".date("Y-m-d H:i:s", $value['end'][$i]-$timeoffset);
194 }
195 }
196 // echo $sessionsStr."<br>-----------<br>";
197
198 $reportarray[$userid]["Sessions"]=$sessionsStr;
199 // $reportarray[$userid]["Signin"]=date("Y-m-d H:i:s", min($value['start'])-$timeoffset);
200 // $reportarray[$userid]["Signout"]=date("Y-m-d H:i:s", max($value['end'])-$timeoffset);
180 $reportarray[$userid]["Duration"]=$value['duration']; 201 $reportarray[$userid]["Duration"]=$value['duration'];
181 $reportarray[$userid]["Total"]=$value['duration']-$break_time; 202 $reportarray[$userid]["Total"]=$value['duration']-$break_time;
182 $reportarray[$userid]["Wait"]=$reportarray[$userid]["Total"]-$reportarray[$userid]['oncall']; 203 $reportarray[$userid]["Wait"]=$reportarray[$userid]["Total"]-$reportarray[$userid]['oncall'];
183 } 204 }
184 205
206 // echo "<pre>"; print_r($userLogin);
207 // exit;
208
185 $highestColumn = sizeof($reporthead); 209 $highestColumn = sizeof($reporthead);
186 if(count($reportarray)) { 210 if(count($reportarray)) {
187 $outhead="<tr>";$outstr=""; 211 $outhead="<tr>";$outstr="";
188 for ($head = 0; $head < $highestColumn; $head++){ 212 for ($head = 0; $head < $highestColumn; $head++){
189 if($reporthead[$head] == '#') { 213 if($reporthead[$head] == "Sessions"){
190 $mode_str = "<a onclick='displayMode(".'"summation"'.");return false;' href='#'><i class='fa fa-plus-square-o'></i></a> / <a onclick='displayMode(".'"percent"'.");return false;' href='#'>%</a>"; 214 $outhead.="<td style='width:270px;display:block;'>".$reporthead[$head]."</td>";
191 $outhead.="<td>".$mode_str."</td>"; 215 }else{
192 }
193 else {
194 $outhead.="<td>".$reporthead[$head]."</td>"; 216 $outhead.="<td>".$reporthead[$head]."</td>";
195 } 217 }
196 } 218 }
197 $outhead.="</tr>"; 219 $outhead.="</tr>";
198 $utotalarr = array("Telecaller"=>'Total'); 220 $utotalarr = array("Telecaller"=>'Total');
199 221
222 $reportRowNo = 1;
200 foreach($reportarray as $uid=>$uarr) 223 foreach($reportarray as $uid=>$uarr)
201 { 224 {
202 if(array_key_exists('Signin',$uarr)) 225 if(array_key_exists('Duration',$uarr) && array_key_exists('TelecallerID',$uarr))
203 { 226 {
204 $outstr.="<tr>"; 227 $outstr.="<tr>";
205 for ($head = 0; $head < $highestColumn; $head++){ 228 for ($head = 0; $head < $highestColumn; $head++){
206 if($head < 6) { 229 if($head < 1){
230 $data_str = $reportRowNo; $reportRowNo++;
231 }elseif($head < 5) {
232 // if($head < 6) {
207 $data_str = $uarr[$reporthead[$head]]; 233 $data_str = $uarr[$reporthead[$head]];
208 } 234 }
209 elseif($head < 7) { 235 elseif($head < 6) {
210 $data_str = $uarr[$reporthead[$head]]; 236 $data_str = $uarr[$reporthead[$head]];
211 $utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]]; 237 $utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]];
212 } 238 }
...@@ -222,7 +248,7 @@ if(count($reportarray)) { ...@@ -222,7 +248,7 @@ if(count($reportarray)) {
222 $outstr.="<tr>"; 248 $outstr.="<tr>";
223 for ($head = 0; $head < $highestColumn; $head++) 249 for ($head = 0; $head < $highestColumn; $head++)
224 { 250 {
225 if($head < 7) { 251 if($head < 6) {
226 $data_str = $utotalarr[$reporthead[$head]]; 252 $data_str = $utotalarr[$reporthead[$head]];
227 } 253 }
228 else { 254 else {
...@@ -231,8 +257,7 @@ if(count($reportarray)) { ...@@ -231,8 +257,7 @@ if(count($reportarray)) {
231 $outstr.="<td>".$data_str."</td>"; 257 $outstr.="<td>".$data_str."</td>";
232 } 258 }
233 $outstr.="</tr>"; 259 $outstr.="</tr>";
234 } 260 } else {
235 else {
236 $outhead.="<tr><td>No Records Found.</td></tr>"; 261 $outhead.="<tr><td>No Records Found.</td></tr>";
237 } 262 }
238 263
...@@ -258,7 +283,7 @@ if(Input::has("dllogxls")) ...@@ -258,7 +283,7 @@ if(Input::has("dllogxls"))
258 $col = 0; 283 $col = 0;
259 284
260 for ($head = 0; $head < $highestColumn; $head++){ 285 for ($head = 0; $head < $highestColumn; $head++){
261 $excelval = ($head < 7) ? $uarr[$reporthead[$head]] : secToDuration(round($uarr[$reporthead[$head]])); 286 $excelval = ($head < 6) ? $uarr[$reporthead[$head]] : secToDuration(round($uarr[$reporthead[$head]]));
262 $colstr=PHPExcel_Cell::stringFromColumnIndex($head); 287 $colstr=PHPExcel_Cell::stringFromColumnIndex($head);
263 $objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $excelval); 288 $objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $excelval);
264 } 289 }
...@@ -266,7 +291,7 @@ if(Input::has("dllogxls")) ...@@ -266,7 +291,7 @@ if(Input::has("dllogxls"))
266 291
267 $row++; 292 $row++;
268 for ($head = 0; $head < $highestColumn; $head++){ 293 for ($head = 0; $head < $highestColumn; $head++){
269 $excelval = ($head < 7) ? $utotalarr[$reporthead[$head]] : secToDuration(round($utotalarr[$reporthead[$head]])); 294 $excelval = ($head < 6) ? $utotalarr[$reporthead[$head]] : secToDuration(round($utotalarr[$reporthead[$head]]));
270 $colstr=PHPExcel_Cell::stringFromColumnIndex($head); 295 $colstr=PHPExcel_Cell::stringFromColumnIndex($head);
271 $objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $excelval); 296 $objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $excelval);
272 } 297 }
...@@ -286,7 +311,7 @@ function secToDuration($sec) { ...@@ -286,7 +311,7 @@ function secToDuration($sec) {
286 } 311 }
287 ?> 312 ?>
288 313
289 <style>#logtable.td{vertical-align:top;padding:20px;}#logtable.tr{height:28px;overflow-y:hidden;} 314 <style>#logtable.td{vertical-align:top;padding:20px;}#logtable.tr{height:28px;overflow-y:hidden;}
290 /*#logtable.table thead tr{ 315 /*#logtable.table thead tr{
291 display:block; 316 display:block;
292 } 317 }
...@@ -295,17 +320,17 @@ function secToDuration($sec) { ...@@ -295,17 +320,17 @@ function secToDuration($sec) {
295 display:block; 320 display:block;
296 height:500px; 321 height:500px;
297 overflow:auto;//set tbody to auto 322 overflow:auto;//set tbody to auto
298 }*/ 323 }*/
299 </style> 324 </style>
300 325
301 <div class=innerAll> 326 <div class=innerAll>
302 <h4 style="float:left;width:50%;margin:10px 0;">Agent Time Report</h4> 327 <h4 style="float:left;width:50%;margin:10px 0;">Login Report <small>(Agent Time Report)</small></h4>
303 <div style="float:right;width:50%"> 328 <div style="float:right;width:50%">
304 <button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download'><i class='fa fa-download'></i> Download</button> 329 <button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download'><i class='fa fa-download'></i> Download</button>
305 </div> 330 </div>
306 <div style="clear:both"></div> 331 <div style="clear:both"></div>
307 <hr style="margin-bottom: 5px;"> 332 <hr style="margin-bottom: 5px;">
308 <div> 333 <div>
309 Search <input id=filter name="filter" type="text" style="border:1px solid #efefef; padding: 2px 10px;">&nbsp;&nbsp; 334 Search <input id=filter name="filter" type="text" style="border:1px solid #efefef; padding: 2px 10px;">&nbsp;&nbsp;
310 Date: From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='statusLogReloadFun("");' /> 335 Date: From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='statusLogReloadFun("");' />
311 <select id="modtime" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'> 336 <select id="modtime" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
...@@ -314,7 +339,8 @@ function secToDuration($sec) { ...@@ -314,7 +339,8 @@ function secToDuration($sec) {
314 $selected = ($hour == $logtime) ? "selected" : ""; 339 $selected = ($hour == $logtime) ? "selected" : "";
315 echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>"; 340 echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
316 } 341 }
317 ?></select> 342 ?>
343 </select>
318 To <input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logdateto); ?>' onchange='statusLogReloadFun("");' /> 344 To <input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logdateto); ?>' onchange='statusLogReloadFun("");' />
319 <select id="modtimeto" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'> 345 <select id="modtimeto" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
320 <?php 346 <?php
...@@ -327,19 +353,19 @@ function secToDuration($sec) { ...@@ -327,19 +353,19 @@ function secToDuration($sec) {
327 <select id="campaign" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'> 353 <select id="campaign" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
328 <?php foreach($oclientlst as $c){$s="";if($c==$campaign)$s='selected';echo "<option value='$c' $s>$c</option>";} ?> 354 <?php foreach($oclientlst as $c){$s="";if($c==$campaign)$s='selected';echo "<option value='$c' $s>$c</option>";} ?>
329 </select> 355 </select>
330 </div> 356 </div>
331 357
332 <div style="clear:both"></div> 358 <div style="clear:both"></div>
333 <hr style="margin:5px;"> 359 <hr style="margin:5px;">
334 360
335 <div style="overflow: auto; margin-top: 10px;"> 361 <div style="overflow: auto; margin-top: 10px;">
336 <table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px; margin:0; border:1px solid #BBB;'> 362 <table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px; margin:0; border:1px solid #BBB;'>
337 <thead><?php echo $outhead; ?></thead> 363 <thead><?php echo $outhead; ?></thead>
338 <?php echo $outstr; ?> 364 <tbody id="logTableData"><?php echo $outstr; ?></tbody>
339 </table> 365 </table>
340 </div> 366 </div>
341 367
342 <div id=dialoglog></div> 368 <div id=dialoglog></div>
343 </div> 369 </div>
344 370
345 <script> 371 <script>
...@@ -359,8 +385,7 @@ $(document).ready(function() { ...@@ -359,8 +385,7 @@ $(document).ready(function() {
359 } 385 }
360 }); 386 });
361 } 387 }
362 388 waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logTableData') },"2000");
363 waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
364 $('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'}); 389 $('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
365 $('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'}); 390 $('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
366 }); 391 });
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!