862aa821 by Manish Mihsra

Added displaying the date wise report and added logic for downloading the same in excel format

1 parent a47f0232
......@@ -20,6 +20,7 @@ use App\Models\UserLog;
use DB;
use Log;
use Session;
use App\lib\phpexcel\PHPExcel;
class ReportController extends Controller
{
......@@ -181,8 +182,14 @@ class ReportController extends Controller
if($id=="campaignwise")
{
$filename = $id;
$reporthead = ["Campaign", "Dials", "Connects", "Contacts", "Callbacks", "Sales", "No Answer", "Busy", "Sit Tones", "Abandoned", "Connect %", "No Answer %", "Busy %", "Sit Tones %", "Abandoned %"];
$reportArr = $this->getCampaignWisePredictiveDetails($data);
if(Input::has("dllogxls"))$this->downloadReportInExcel($filename, $reporthead, $reportArr);
$data["reportArr"] = $reportArr["reportArr"];
return view("layout.module.reports.campaignwise", $data);
......@@ -192,12 +199,14 @@ class ReportController extends Controller
public function getCampaignWisePredictiveDetails($basicArr)
{
$data = array();
$finalArr = array();
$reportArr = array();
$typeArr = array('Auto', 'AutoCall');
$timeoffset = $basicArr["timeoffset"];
$logdate = $basicArr["logdate"];
$logdateto = $basicArr["logdateto"];
$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();
foreach ($crmcallObjs as $key => $crmcallObj) {
......@@ -206,11 +215,55 @@ class ReportController extends Controller
if($crmcallObj->user_id != 0) $reportArr[$crmcallObj->client]['connects']++;
if(strstr($crmcallObj->status, "NOANSWER"))$reportArr[$crmcallObj->client]['noanswer']++;
if(stristr($crmcallObj->status, "busy"))$reportArr[$crmcallObj->client]['busy']++;
if(strstr($crmcallObj->status, "ANSWER") && $crmcallObj->user_id == 0)$reportArr[$crmcallObj->client]['abandoned']++;
if($crmcallObj->status == "ANSWER" && $crmcallObj->user_id == 0)$reportArr[$crmcallObj->client]['abandoned']++;
if($crmcallObj->status != "ANSWER" && $crmcallObj->status != "NOANSWER" && stristr($crmcallObj->status, "busy") == "")$reportArr[$crmcallObj->client]['sittone']++;
}
foreach ($reportArr as $key => $report) {
$finalArr[$key] = $report;
$finalArr[$key]['connect_per'] = round(($report['connects'] / $report['dials']) * 100, 2);
$finalArr[$key]['noanswer_per'] = round(($report['noanswer'] / $report['dials']) * 100, 2);
$finalArr[$key]['busy_per'] = round(($report['busy'] / $report['dials']) * 100, 2);
$finalArr[$key]['abandoned_per'] = round(($report['abandoned'] / $report['dials']) * 100, 2);
$finalArr[$key]['sittone_per'] = round(($report['sittone'] / $report['dials']) * 100, 2);
}
$data["reportArr"] = $reportArr;
$data["reportArr"] = $finalArr;
return $data;
}
public function downloadReportInExcel($filename, $reporthead, $reportarray)
{
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr[$reporthead[$head]]);
}
$row++;
}
header('Content-Type: application/vnd.ms-excel');
header("Content-Disposition: attachment;filename=\"$filename.xls\"");
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
}
}
......
<?php
<?php namespace App\lib\phpexcel\PHPExcel;
/**
* PHPExcel
*
......
......@@ -1331,7 +1331,7 @@ function filter2 (phrase, _id){
var words = phrase.value.toLowerCase().split(" ");
var table = document.getElementById(_id);
var ele;
for (var r = 0; r < table.rows.length; r++){
for (var r = 1; r < table.rows.length; r++){
ele = table.rows[r].innerHTML.replace(/<[^>]+>/g,"");
var displayStyle = 'none';
for (var i = 0; i < words.length; i++) {
......
......@@ -76,6 +76,9 @@ kstychAppObject['config']['colorInverse']='{!!$skinarr[8]!!}';
<script src="{!!url('/')!!}/assets/components/modules/admin/chat/chatboxmanager.js"></script>
<script src="{!!url('/')!!}/assets/js/highchart/highcharts.js"></script>
<script src="{!!url('/')!!}/jsbody?v={!!$v!!}"></script>
<script src="{!!url('/')!!}/assets/js/sip.js"></script>
<script src="{!!url('/')!!}/assets/js/dialer.js"></script>
<script src="{!!url('/')!!}/assets/js/kstych.js"></script>
<?php if(Session::has('mdevice')&&Session::get('mdevice')!=""){$md=Session::get('mdevice'); ?>
<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";
// readfile("assets/js/ckeditor/ckeditor.js");echo "\n\n";
readfile("assets/js/sip.js");echo "\n\n";
readfile("assets/js/dialer.js");echo "\n\n";
// readfile("assets/js/sip.js");echo "\n\n";
// readfile("assets/js/dialer.js");echo "\n\n";
readfile("assets/js/kstych.js");echo "\n\n";
// readfile("assets/js/kstych.js");echo "\n\n";
......
<style>#logtable.td{vertical-align:top;padding:20px;}#logtable.tr{height:28px;overflow-y:hidden;}
<style>#logTableData.td{vertical-align:top;padding:20px;}#logTableData.tr{height:28px;overflow-y:hidden;}
/*#logtable.table thead tr{
display:block;
}
......@@ -38,14 +38,14 @@
echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
}
?></select>&nbsp;&nbsp;
<input type="button" value='Submit' class="btn btn-xs btn-info">
<input type="button" value='Submit' class="btn btn-xs btn-info" onclick='statusLogReloadFun("");'>
</div>
<div style="clear:both"></div>
<hr style="margin:5px;">
<div style="overflow: auto; margin-top: 10px;">
<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;'>
<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;'>
<thead>
<th>Campaign</th>
<th>Dials</th>
......@@ -75,13 +75,13 @@
<td></td>
<td>{{$value['noanswer']}}</td>
<td>{{$value['busy']}}</td>
<td></td>
<td>{{$value['sittone']}}</td>
<td>{{$value['abandoned']}}</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>{{$value['connect_per']}}</td>
<td>{{$value['noanswer_per']}}</td>
<td>{{$value['busy_per']}}</td>
<td>{{$value['sittone_per']}}</td>
<td>{{$value['abandoned_per']}}</td>
</tr>
@endforeach
</tbody>
......@@ -115,18 +115,18 @@ $(document).ready(function() {
function dataString()
{
return 'logdate='+$("#modfrom").val()+'&logtime='+$("#modtime").val()+'&logdateto='+$("#modto").val()+'&logtimeto='+$("#modtimeto").val()+'&campaign='+$("#campaign").val();
return 'logdate='+$("#modfrom").val()+'&logtime='+$("#modtime").val()+'&logdateto='+$("#modto").val()+'&logtimeto='+$("#modtimeto").val();
}
function statusLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
var searchStr = dataString();
doAjax('dialer/campaignwise?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
doAjax('report/campaignwise?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
var searchStr = dataString();
//window.open('dialer/agenttime?dllogxls=1&'+searchStr);
window.open('report/campaignwise?dllogxls=1&'+searchStr);
return false;
}
</script>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!