Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flexydial
/
hdfc-beu-v2
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
167db9a5
authored
2019-08-20 10:21:03 +0000
by
Manish Mihsra
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Added downloading report in excel format
1 parent
5523f66a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
129 additions
and
51 deletions
application/app/Http/Controllers/ReportController.php
application/resources/views/layout/module/reports/campaignwise.blade.php
application/app/Http/Controllers/ReportController.php
View file @
167db9a
...
...
@@ -20,7 +20,7 @@ use App\Models\UserLog;
use
DB
;
use
Log
;
use
Session
;
use
App\lib\
phpexcel\PHPExcel
;
use
App\lib\
PHP_XLSXWriter_master\XLSXWriter
;
class
ReportController
extends
Controller
{
...
...
@@ -183,14 +183,21 @@ class ReportController extends Controller
if
(
$id
==
"campaignwise"
)
{
$filename
=
$id
;
$dllogxls
=
Input
::
get
(
'dllogxls'
);
$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
[
"dllogxls"
]
=
$dllogxls
;
$data
[
"filename"
]
=
$filename
;
$data
[
"reporthead"
]
=
$reporthead
;
$data
[
"reportArr"
]
=
$reportArr
[
"reportArr"
];
$newReportArr
=
array_map
(
function
(
$val
,
$key
){
return
[
'campaign'
=>
$key
]
+
$val
;
},
$reportArr
[
'reportArr'
],
array_keys
(
$reportArr
[
'reportArr'
]));
$data
[
"reportArr"
]
=
$newReportArr
;
return
view
(
"layout.module.reports.campaignwise"
,
$data
);
}
...
...
@@ -213,20 +220,31 @@ class ReportController extends Controller
$reportArr
[
$crmcallObj
->
client
][
'dials'
]
++
;
if
(
$crmcallObj
->
user_id
!=
0
)
$reportArr
[
$crmcallObj
->
client
][
'connects'
]
++
;
if
(
strstr
(
$crmcallObj
->
status
,
"NOANSWER"
))
$reportArr
[
$crmcallObj
->
client
][
'noanswer'
]
++
;
if
(
strstr
(
$crmcallObj
->
status
,
"NOANSWER"
))
$reportArr
[
$crmcallObj
->
client
][
'no_answer'
]
++
;
if
(
stristr
(
$crmcallObj
->
status
,
"busy"
))
$reportArr
[
$crmcallObj
->
client
][
'busy'
]
++
;
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
][
'sit
tone
'
]
++
;
if
(
$crmcallObj
->
status
!=
"ANSWER"
&&
$crmcallObj
->
status
!=
"NOANSWER"
&&
stristr
(
$crmcallObj
->
status
,
"busy"
)
==
""
)
$reportArr
[
$crmcallObj
->
client
][
'sit
_tones
'
]
++
;
}
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
);
if
(
!
isset
(
$finalArr
[
$key
][
'dials'
]))
$finalArr
[
$key
][
'dials'
]
=
0
;
if
(
!
isset
(
$finalArr
[
$key
][
'connects'
]))
$finalArr
[
$key
][
'connects'
]
=
0
;
if
(
!
isset
(
$finalArr
[
$key
][
'contacts'
]))
$finalArr
[
$key
][
'contacts'
]
=
0
;
if
(
!
isset
(
$finalArr
[
$key
][
'callbacks'
]))
$finalArr
[
$key
][
'callbacks'
]
=
0
;
if
(
!
isset
(
$finalArr
[
$key
][
'sales'
]))
$finalArr
[
$key
][
'sales'
]
=
0
;
if
(
!
isset
(
$finalArr
[
$key
][
'no_answer'
]))
$finalArr
[
$key
][
'no_answer'
]
=
0
;
if
(
!
isset
(
$finalArr
[
$key
][
'busy'
]))
$finalArr
[
$key
][
'busy'
]
=
0
;
if
(
!
isset
(
$finalArr
[
$key
][
'sit_tones'
]))
$finalArr
[
$key
][
'sit_tones'
]
=
0
;
if
(
!
isset
(
$finalArr
[
$key
][
'abandoned'
]))
$finalArr
[
$key
][
'abandoned'
]
=
0
;
$finalArr
[
$key
][
'connects_per'
]
=
round
((
$report
[
'connects'
]
/
$report
[
'dials'
])
*
100
,
2
);
$finalArr
[
$key
][
'no_answer_per'
]
=
round
((
$report
[
'no_answer'
]
/
$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
][
'sit
tone_per'
]
=
round
((
$report
[
'sittone
'
]
/
$report
[
'dials'
])
*
100
,
2
);
$finalArr
[
$key
][
'sit
_tones_per'
]
=
round
((
$report
[
'sit_tones
'
]
/
$report
[
'dials'
])
*
100
,
2
);
}
$data
[
"reportArr"
]
=
$finalArr
;
...
...
@@ -234,36 +252,42 @@ class ReportController extends Controller
return
$data
;
}
public
function
downloadReportInExcel
(
$filename
,
$reporthead
,
$reportarray
)
//TODO: Need To make common Download Function
public
function
downloadReportInExcel
(
$data
)
{
$inputFileType
=
"Excel5"
;
$objReader
=
PHPExcel_IOFactory
::
createReader
(
$inputFileType
);
$objPHPExcel
=
$objReader
->
load
(
"assets/extras/blank.xls"
);
$baseRow
=
2
;
$headerexcel
=
[];
$filename
=
$data
[
"filename"
];
$filename
=
$filename
.
".xlsx"
;
$reporthead
=
$data
[
"reporthead"
];
$reportArr
=
$data
[
"reportArr"
];
$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
)
foreach
(
$reporthead
as
$cachekey
)
{
$row
=
$baseRow
++
;
$col
=
0
;
for
(
$head
=
0
;
$head
<
$highestColumn
;
$head
++
){
$colstr
=
PHPExcel_Cell
::
stringFromColumnIndex
(
$head
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
$colstr
.
$row
,
$uarr
[
$reporthead
[
$head
]]);
if
(
$cachekey
!=
''
)
{
$headerexcel
[
$cachekey
]
=
'string'
;
}
$row
++
;
}
header
(
'Content-Type: application/vnd.ms-excel'
);
header
(
"Content-Disposition: attachment;filename=
\"
$filename
.xls
\"
"
);
header
(
'Cache-Control: max-age=0'
);
header
(
'Content-disposition: attachment; filename="'
.
XLSXWriter
::
sanitize_filename
(
$filename
)
.
'"'
);
header
(
"Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
);
header
(
'Content-Transfer-Encoding: binary'
);
header
(
'Cache-Control: must-revalidate'
);
header
(
'Pragma: public'
);
$objWriter
=
PHPExcel_IOFactory
::
createWriter
(
$objPHPExcel
,
$inputFileType
);
$objWriter
->
save
(
'php://output'
);
$writer
=
new
XLSXWriter
();
$styles1
=
array
(
'font'
=>
'Arial'
,
'font-size'
=>
10
,
'font-style'
=>
'bold'
,
'fill'
=>
'#eee'
,
'halign'
=>
'center'
,
'border'
=>
'left,right,top,bottom'
);
$writer
->
writeSheetHeader
(
'Sheet1'
,
$headerexcel
,
$styles1
,[
'freeze_rows'
=>
1
,
'freeze_columns'
=>
1
]);
if
(
$reportArr
){
foreach
(
$reportArr
as
$row
)
{
$writer
->
writeSheetRow
(
'Sheet1'
,
$row
,
$row_options
=
[
'height'
=>
15
]);
}
}
//dd($writer);
$writer
->
writeToStdOut
();
}
}
...
...
application/resources/views/layout/module/reports/campaignwise.blade.php
View file @
167db9a
<style>
#logTableData
.td
{
vertical-align
:
top
;
padding
:
20px
;}
#logTableData
.tr
{
height
:
28px
;
overflow-y
:
hidden
;}
/*#logtable.table thead tr{
display:block;
@php
if($dllogxls)
{
include_once(app_path().'/lib/PHP_XLSXWriter_master/xlsxwriter.class.php');
$headerexcel = [];
$filename = $filename.".xlsx";
foreach($reporthead as $cachekey)
{
if($cachekey!='')
{
$headerexcel[$cachekey] = 'string';
}
}
header('Content-disposition: attachment; filename="'.XLSXWriter::sanitize_filename($filename).'"');
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate');
header('Pragma: public');
$writer = new XLSXWriter();
$styles1 = array( 'font'=>'Arial','font-size'=>10,'font-style'=>'bold', 'fill'=>'#eee', 'halign'=>'center', 'border'=>'left,right,top,bottom');
$writer->writeSheetHeader('Sheet1', $headerexcel,$styles1,['freeze_rows'=>1, 'freeze_columns'=>1]);
if($reportArr){
foreach($reportArr as $row)
{
$newRow = [];
$newRow['campaign'] = $row['campaign'];
$newRow['dials'] = $row['dials'];
$newRow['connects'] = $row['connects'];
$newRow['contacts'] = $row['contacts'];
$newRow['callbacks'] = $row['callbacks'];
$newRow['sales'] = $row['sales'];
$newRow['no_answer'] = $row['no_answer'];
$newRow['busy'] = $row['busy'];
$newRow['sit_tones'] = $row['sit_tones'];
$newRow['abandoned'] = $row['abandoned'];
$newRow['connects_per'] = $row['connects_per'];
$newRow['no_answer_per'] = $row['no_answer_per'];
$newRow['busy_per'] = $row['busy_per'];
$newRow['sit_tones_per'] = $row['sit_tones_per'];
$newRow['abandoned_per'] = $row['abandoned_per'];
$writer->writeSheetRow('Sheet1', $newRow, $newRow_options = ['height'=>15]);
}
}
$writer->writeToStdOut();
return;
}
#logtable.table tbody{
display:block;
height:500px;
overflow:auto;//set tbody to auto
}*/
@endphp
<style>
#logTableData
.td
{
vertical-align
:
top
;
padding
:
20px
;}
#logTableData
.tr
{
height
:
28px
;
overflow-y
:
hidden
;}
</style>
<div
class=
innerAll
>
...
...
@@ -65,23 +119,23 @@
</thead>
<tbody>
@foreach($reportArr as $
client=>$
value)
@foreach($reportArr as $value)
<tr>
<td>
{{$
client
}}
</td>
<td>
{{$
value['campaign']
}}
</td>
<td>
{{$value['dials']}}
</td>
<td>
{{$value['connects']}}
</td>
<td></td>
<td></td>
<td></td>
<td>
{{$value['noanswer']}}
</td>
<td>
{{$value['contacts']}}
</td>
<td>
{{$value['callbacks']}}
</td>
<td>
{{$value['sales']}}
</td>
<td>
{{$value['no
_
answer']}}
</td>
<td>
{{$value['busy']}}
</td>
<td>
{{$value['sit
tone
']}}
</td>
<td>
{{$value['sit
_tones
']}}
</td>
<td>
{{$value['abandoned']}}
</td>
<td>
{{$value['connect
_per']}}
</td>
<td>
{{$value['no
answer_per']}}
</td>
<td>
{{$value['busy_per']}}
</td>
<td>
{{$value['sit
tone_per']}}
</td>
<td>
{{$value['abandoned_per']}}
</td>
<td>
{{$value['connect
s_per']}}
<span>
%
</span>
</td>
<td>
{{$value['no
_answer_per']}}
<span>
%
</span>
</td>
<td>
{{$value['busy_per']}}
<
span>
%
</span><
/td>
<td>
{{$value['sit
_tones_per']}}
<span>
%
</span>
</td>
<td>
{{$value['abandoned_per']}}
<
span>
%
</span><
/td>
</tr>
@endforeach
</tbody>
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment