disporeport.blade.php
5.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
$reportTitle = 'Disposition Report';
$returnblade = 'disporeport';
$view_path = Config::get('view.paths');
include_once($view_path[0].'/layout/module/dialer/reporthead.blade.php');
$alist=$alist->whereIn('userstatus',array('Interested', 'Reprised', 'No contact', 'Not Interested', 'Not Eligible', 'FollowUp'));
$alist=$alist->get();
$i=1;
$reporthead=array("#","Employee id","Agent Name","Campaign","Customers","Attempts","Contacts","Interested","Interested%","FollowUp","Not Interested","Not Eligible","Reprised","No contact");
$reportarray=array();
if(count($alist))
foreach($alist as $aline)
{
$tuser=$userarr[$aline->user_id];
$arraykey = $aline->user_id.$aline->client;
if(!isset($reportarray[$arraykey]))$reportarray[$arraykey]=array("#"=>$i++,"Agent Name"=>$tuser->telecaller,"Employee id"=>$tuser->username,"Campaign"=>$aline->client,"Customers"=>0,"Attempts"=>0,"Contacts"=>0,"Customer_lists"=>array());
if(!is_null($aline->crm_id)) {
$reportarray[$arraykey]["Customer_lists"][] = $aline->crm_id;
}
$reportarray[$arraykey]["Customers"] = count(array_unique($reportarray[$arraykey]["Customer_lists"]));
$reportarray[$arraykey]["Attempts"]++;
if($aline->userstatus != 'No contact')$reportarray[$arraykey]["Contacts"]++;
$ststr=$aline->userstatus;
if(!in_array($ststr,$reporthead))$reporthead[]=$ststr;
$reportarray[$arraykey][$ststr]++;
}
$highestColumn = sizeof($reporthead);
if(count($reportarray)) {
$outhead="<tr>";$outstr="";
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head] == '#' && false) {
$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>";
$outhead.="<td>".$mode_str."</td>";
}
else {
$outhead.="<td>".$reporthead[$head]."</td>";
}
}
$outhead.="</tr>";
$utotalarr = array("Agent Name"=>'Total');
foreach($reportarray as $uid=>$uarr)
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
if($head < 4) {
$data_str = $uarr[$reporthead[$head]];
}
elseif($head == 8) {
$data_str = number_format(@($uarr[$reporthead[7]]/$uarr['Customers']) * 100, 2 ) . '%';
}
elseif($head < 50) {
$data_str = $uarr[$reporthead[$head]];
$utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]];
}
else {
$data_str = '<span class="summation" style="display:block;">'.$uarr[$reporthead[$head]].'</span>';
$data_str .= '<span class="percent" style="display:none;">'.number_format(@($uarr[$reporthead[$head]]/$uarr['Attempts']) * 100, 2 ).'%</span>';
$utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]];
}
$outstr.="<td>".$data_str."</td>";
}
$outstr.="</tr>";
}
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++)
{
if($head == 8) {
$data_str = number_format(@($utotalarr[$reporthead[7]]/$utotalarr['Customers']) * 100, 2 ) . '%';
}
elseif($head < 50) {
$data_str = $utotalarr[$reporthead[$head]];
}
else {
$data_str = '<span class="summation" style="display:block;">'.$utotalarr[$reporthead[$head]].'</span>';
$data_str .= '<span class="percent" style="display:none;">'.number_format(@($utotalarr[$reporthead[$head]]/$utotalarr['Attempts']) * 100, 2 ).'%</span>';
}
$outstr.="<td>".$data_str."</td>";
}
$outstr.="</tr>";
}
else {
$outhead.="<tr><td>No Records Found.</td></tr>";
}
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$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++){
$printval = ($head != 8) ? $uarr[$reporthead[$head]] : number_format(@($uarr[$reporthead[7]]/$uarr['Customers']) * 100, 2 ) . '%';
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $printval);
}
}
$row++;
for ($head = 0; $head < $highestColumn; $head++){
$printval = ($head != 8) ? $utotalarr[$reporthead[$head]] : number_format(@($utotalarr[$reporthead[7]]/$utotalarr['Customers']) * 100, 2 ) . '%';
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $printval);
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Disposition.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
?>
@include('layout.module.dialer.searchform')
<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;'>
<thead><?php echo $outhead; ?></thead>
<?php echo $outstr; ?>
</table>
</div>
</div>