Added displaying the date wise report and added logic for downloading the same in excel format
Showing
6 changed files
with
75 additions
and
19 deletions
| ... | @@ -20,6 +20,7 @@ use App\Models\UserLog; | ... | @@ -20,6 +20,7 @@ use App\Models\UserLog; |
| 20 | use DB; | 20 | use DB; |
| 21 | use Log; | 21 | use Log; |
| 22 | use Session; | 22 | use Session; |
| 23 | use App\lib\phpexcel\PHPExcel; | ||
| 23 | 24 | ||
| 24 | class ReportController extends Controller | 25 | class ReportController extends Controller |
| 25 | { | 26 | { |
| ... | @@ -181,8 +182,14 @@ class ReportController extends Controller | ... | @@ -181,8 +182,14 @@ class ReportController extends Controller |
| 181 | 182 | ||
| 182 | if($id=="campaignwise") | 183 | if($id=="campaignwise") |
| 183 | { | 184 | { |
| 185 | $filename = $id; | ||
| 186 | |||
| 187 | $reporthead = ["Campaign", "Dials", "Connects", "Contacts", "Callbacks", "Sales", "No Answer", "Busy", "Sit Tones", "Abandoned", "Connect %", "No Answer %", "Busy %", "Sit Tones %", "Abandoned %"]; | ||
| 188 | |||
| 184 | $reportArr = $this->getCampaignWisePredictiveDetails($data); | 189 | $reportArr = $this->getCampaignWisePredictiveDetails($data); |
| 185 | 190 | ||
| 191 | if(Input::has("dllogxls"))$this->downloadReportInExcel($filename, $reporthead, $reportArr); | ||
| 192 | |||
| 186 | $data["reportArr"] = $reportArr["reportArr"]; | 193 | $data["reportArr"] = $reportArr["reportArr"]; |
| 187 | 194 | ||
| 188 | return view("layout.module.reports.campaignwise", $data); | 195 | return view("layout.module.reports.campaignwise", $data); |
| ... | @@ -192,12 +199,14 @@ class ReportController extends Controller | ... | @@ -192,12 +199,14 @@ class ReportController extends Controller |
| 192 | public function getCampaignWisePredictiveDetails($basicArr) | 199 | public function getCampaignWisePredictiveDetails($basicArr) |
| 193 | { | 200 | { |
| 194 | $data = array(); | 201 | $data = array(); |
| 202 | $finalArr = array(); | ||
| 195 | $reportArr = array(); | 203 | $reportArr = array(); |
| 196 | $typeArr = array('Auto', 'AutoCall'); | 204 | $typeArr = array('Auto', 'AutoCall'); |
| 197 | $timeoffset = $basicArr["timeoffset"]; | 205 | $timeoffset = $basicArr["timeoffset"]; |
| 198 | $logdate = $basicArr["logdate"]; | 206 | $logdate = $basicArr["logdate"]; |
| 199 | $logdateto = $basicArr["logdateto"]; | 207 | $logdateto = $basicArr["logdateto"]; |
| 200 | 208 | ||
| 209 | |||
| 201 | $crmcallObjs = CRMCall::whereIn('type', $typeArr)->where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset))->get(); | 210 | $crmcallObjs = CRMCall::whereIn('type', $typeArr)->where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset))->get(); |
| 202 | 211 | ||
| 203 | foreach ($crmcallObjs as $key => $crmcallObj) { | 212 | foreach ($crmcallObjs as $key => $crmcallObj) { |
| ... | @@ -206,11 +215,55 @@ class ReportController extends Controller | ... | @@ -206,11 +215,55 @@ class ReportController extends Controller |
| 206 | if($crmcallObj->user_id != 0) $reportArr[$crmcallObj->client]['connects']++; | 215 | if($crmcallObj->user_id != 0) $reportArr[$crmcallObj->client]['connects']++; |
| 207 | if(strstr($crmcallObj->status, "NOANSWER"))$reportArr[$crmcallObj->client]['noanswer']++; | 216 | if(strstr($crmcallObj->status, "NOANSWER"))$reportArr[$crmcallObj->client]['noanswer']++; |
| 208 | if(stristr($crmcallObj->status, "busy"))$reportArr[$crmcallObj->client]['busy']++; | 217 | if(stristr($crmcallObj->status, "busy"))$reportArr[$crmcallObj->client]['busy']++; |
| 209 | if(strstr($crmcallObj->status, "ANSWER") && $crmcallObj->user_id == 0)$reportArr[$crmcallObj->client]['abandoned']++; | 218 | if($crmcallObj->status == "ANSWER" && $crmcallObj->user_id == 0)$reportArr[$crmcallObj->client]['abandoned']++; |
| 219 | if($crmcallObj->status != "ANSWER" && $crmcallObj->status != "NOANSWER" && stristr($crmcallObj->status, "busy") == "")$reportArr[$crmcallObj->client]['sittone']++; | ||
| 210 | } | 220 | } |
| 211 | 221 | ||
| 212 | $data["reportArr"] = $reportArr; | 222 | foreach ($reportArr as $key => $report) { |
| 223 | $finalArr[$key] = $report; | ||
| 224 | |||
| 225 | $finalArr[$key]['connect_per'] = round(($report['connects'] / $report['dials']) * 100, 2); | ||
| 226 | $finalArr[$key]['noanswer_per'] = round(($report['noanswer'] / $report['dials']) * 100, 2); | ||
| 227 | $finalArr[$key]['busy_per'] = round(($report['busy'] / $report['dials']) * 100, 2); | ||
| 228 | $finalArr[$key]['abandoned_per'] = round(($report['abandoned'] / $report['dials']) * 100, 2); | ||
| 229 | $finalArr[$key]['sittone_per'] = round(($report['sittone'] / $report['dials']) * 100, 2); | ||
| 230 | } | ||
| 231 | |||
| 232 | $data["reportArr"] = $finalArr; | ||
| 213 | 233 | ||
| 214 | return $data; | 234 | return $data; |
| 215 | } | 235 | } |
| 236 | |||
| 237 | public function downloadReportInExcel($filename, $reporthead, $reportarray) | ||
| 238 | { | ||
| 239 | $inputFileType = "Excel5"; | ||
| 240 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); | ||
| 241 | $objPHPExcel = $objReader->load("assets/extras/blank.xls"); | ||
| 242 | $baseRow = 2; | ||
| 243 | |||
| 244 | |||
| 245 | $highestColumn = sizeof($reporthead); | ||
| 246 | for ($head = 0; $head < $highestColumn; $head++){ | ||
| 247 | $colstr=PHPExcel_Cell::stringFromColumnIndex($head); | ||
| 248 | $objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]); | ||
| 249 | } | ||
| 250 | foreach($reportarray as $uid=>$uarr) | ||
| 251 | { | ||
| 252 | $row = $baseRow++; | ||
| 253 | $col = 0; | ||
| 254 | |||
| 255 | for ($head = 0; $head < $highestColumn; $head++){ | ||
| 256 | $colstr=PHPExcel_Cell::stringFromColumnIndex($head); | ||
| 257 | $objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr[$reporthead[$head]]); | ||
| 258 | } | ||
| 259 | $row++; | ||
| 260 | } | ||
| 261 | |||
| 262 | header('Content-Type: application/vnd.ms-excel'); | ||
| 263 | header("Content-Disposition: attachment;filename=\"$filename.xls\""); | ||
| 264 | header('Cache-Control: max-age=0'); | ||
| 265 | |||
| 266 | $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType); | ||
| 267 | $objWriter->save('php://output'); | ||
| 268 | } | ||
| 216 | } | 269 | } | ... | ... |
| ... | @@ -1331,7 +1331,7 @@ function filter2 (phrase, _id){ | ... | @@ -1331,7 +1331,7 @@ function filter2 (phrase, _id){ |
| 1331 | var words = phrase.value.toLowerCase().split(" "); | 1331 | var words = phrase.value.toLowerCase().split(" "); |
| 1332 | var table = document.getElementById(_id); | 1332 | var table = document.getElementById(_id); |
| 1333 | var ele; | 1333 | var ele; |
| 1334 | for (var r = 0; r < table.rows.length; r++){ | 1334 | for (var r = 1; r < table.rows.length; r++){ |
| 1335 | ele = table.rows[r].innerHTML.replace(/<[^>]+>/g,""); | 1335 | ele = table.rows[r].innerHTML.replace(/<[^>]+>/g,""); |
| 1336 | var displayStyle = 'none'; | 1336 | var displayStyle = 'none'; |
| 1337 | for (var i = 0; i < words.length; i++) { | 1337 | for (var i = 0; i < words.length; i++) { | ... | ... |
| ... | @@ -76,6 +76,9 @@ kstychAppObject['config']['colorInverse']='{!!$skinarr[8]!!}'; | ... | @@ -76,6 +76,9 @@ 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 src="{!!url('/')!!}/jsbody?v={!!$v!!}"></script> | 78 | <script src="{!!url('/')!!}/jsbody?v={!!$v!!}"></script> |
| 79 | <script src="{!!url('/')!!}/assets/js/sip.js"></script> | ||
| 80 | <script src="{!!url('/')!!}/assets/js/dialer.js"></script> | ||
| 81 | <script src="{!!url('/')!!}/assets/js/kstych.js"></script> | ||
| 79 | 82 | ||
| 80 | <?php if(Session::has('mdevice')&&Session::get('mdevice')!=""){$md=Session::get('mdevice'); ?> | 83 | <?php if(Session::has('mdevice')&&Session::get('mdevice')!=""){$md=Session::get('mdevice'); ?> |
| 81 | <script src="{!!url('/')!!}/assets/js/cordova/{!!$md!!}/cordova.js?v={!!$v!!}"></script> | 84 | <script src="{!!url('/')!!}/assets/js/cordova/{!!$md!!}/cordova.js?v={!!$v!!}"></script> | ... | ... |
| ... | @@ -70,7 +70,7 @@ readfile("assets/components/modules/admin/waves/waves.js");echo "\n\n"; | ... | @@ -70,7 +70,7 @@ readfile("assets/components/modules/admin/waves/waves.js");echo "\n\n"; |
| 70 | // readfile("assets/js/ckeditor/ckeditor.js");echo "\n\n"; | 70 | // readfile("assets/js/ckeditor/ckeditor.js");echo "\n\n"; |
| 71 | 71 | ||
| 72 | 72 | ||
| 73 | readfile("assets/js/sip.js");echo "\n\n"; | 73 | // readfile("assets/js/sip.js");echo "\n\n"; |
| 74 | readfile("assets/js/dialer.js");echo "\n\n"; | 74 | // readfile("assets/js/dialer.js");echo "\n\n"; |
| 75 | 75 | ||
| 76 | readfile("assets/js/kstych.js");echo "\n\n"; | 76 | // readfile("assets/js/kstych.js");echo "\n\n"; | ... | ... |
| 1 | <style>#logtable.td{vertical-align:top;padding:20px;}#logtable.tr{height:28px;overflow-y:hidden;} | 1 | <style>#logTableData.td{vertical-align:top;padding:20px;}#logTableData.tr{height:28px;overflow-y:hidden;} |
| 2 | /*#logtable.table thead tr{ | 2 | /*#logtable.table thead tr{ |
| 3 | display:block; | 3 | display:block; |
| 4 | } | 4 | } |
| ... | @@ -38,14 +38,14 @@ | ... | @@ -38,14 +38,14 @@ |
| 38 | echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>"; | 38 | echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>"; |
| 39 | } | 39 | } |
| 40 | ?></select> | 40 | ?></select> |
| 41 | <input type="button" value='Submit' class="btn btn-xs btn-info"> | 41 | <input type="button" value='Submit' class="btn btn-xs btn-info" onclick='statusLogReloadFun("");'> |
| 42 | </div> | 42 | </div> |
| 43 | 43 | ||
| 44 | <div style="clear:both"></div> | 44 | <div style="clear:both"></div> |
| 45 | <hr style="margin:5px;"> | 45 | <hr style="margin:5px;"> |
| 46 | 46 | ||
| 47 | <div style="overflow: auto; margin-top: 10px;"> | 47 | <div style="overflow: auto; margin-top: 10px;"> |
| 48 | <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;'> | 48 | <table id=logTableData class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px; margin:0; border:1px solid #BBB;'> |
| 49 | <thead> | 49 | <thead> |
| 50 | <th>Campaign</th> | 50 | <th>Campaign</th> |
| 51 | <th>Dials</th> | 51 | <th>Dials</th> |
| ... | @@ -75,13 +75,13 @@ | ... | @@ -75,13 +75,13 @@ |
| 75 | <td></td> | 75 | <td></td> |
| 76 | <td>{{$value['noanswer']}}</td> | 76 | <td>{{$value['noanswer']}}</td> |
| 77 | <td>{{$value['busy']}}</td> | 77 | <td>{{$value['busy']}}</td> |
| 78 | <td></td> | 78 | <td>{{$value['sittone']}}</td> |
| 79 | <td>{{$value['abandoned']}}</td> | 79 | <td>{{$value['abandoned']}}</td> |
| 80 | <td></td> | 80 | <td>{{$value['connect_per']}}</td> |
| 81 | <td></td> | 81 | <td>{{$value['noanswer_per']}}</td> |
| 82 | <td></td> | 82 | <td>{{$value['busy_per']}}</td> |
| 83 | <td></td> | 83 | <td>{{$value['sittone_per']}}</td> |
| 84 | <td></td> | 84 | <td>{{$value['abandoned_per']}}</td> |
| 85 | </tr> | 85 | </tr> |
| 86 | @endforeach | 86 | @endforeach |
| 87 | </tbody> | 87 | </tbody> |
| ... | @@ -115,18 +115,18 @@ $(document).ready(function() { | ... | @@ -115,18 +115,18 @@ $(document).ready(function() { |
| 115 | 115 | ||
| 116 | function dataString() | 116 | function dataString() |
| 117 | { | 117 | { |
| 118 | return 'logdate='+$("#modfrom").val()+'&logtime='+$("#modtime").val()+'&logdateto='+$("#modto").val()+'&logtimeto='+$("#modtimeto").val()+'&campaign='+$("#campaign").val(); | 118 | return 'logdate='+$("#modfrom").val()+'&logtime='+$("#modtime").val()+'&logdateto='+$("#modto").val()+'&logtimeto='+$("#modtimeto").val(); |
| 119 | } | 119 | } |
| 120 | function statusLogReloadFun(sortby) | 120 | function statusLogReloadFun(sortby) |
| 121 | { | 121 | { |
| 122 | var sortstr='';if(sortby!="")sortstr="&sort="+sortby | 122 | var sortstr='';if(sortby!="")sortstr="&sort="+sortby |
| 123 | var searchStr = dataString(); | 123 | var searchStr = dataString(); |
| 124 | doAjax('dialer/campaignwise?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET'); | 124 | doAjax('report/campaignwise?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET'); |
| 125 | } | 125 | } |
| 126 | function dlAgentlogXls() | 126 | function dlAgentlogXls() |
| 127 | { | 127 | { |
| 128 | var searchStr = dataString(); | 128 | var searchStr = dataString(); |
| 129 | //window.open('dialer/agenttime?dllogxls=1&'+searchStr); | 129 | window.open('report/campaignwise?dllogxls=1&'+searchStr); |
| 130 | return false; | 130 | return false; |
| 131 | } | 131 | } |
| 132 | </script> | 132 | </script> | ... | ... |
-
Please register or sign in to post a comment