breakupxls.blade.php
6.06 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
150
151
152
153
154
155
156
157
158
<?php
if(Input::has("report"))
{
$view_path = Config::get('view.paths');
include_once($view_path[0].'/layout/module/dialer/reporthead.blade.php');
$userId =(isset($_GET['userId'])) ? $_GET['userId'] : "All";
if($userId != 'All') $alist->where('c.user_id','=',Input::get('userId'));
switch (Input::get("report")) {
case 'contactability':
$alist->whereIn('c.userstatus', array("Contacted", "Not Contacted", "FORCEDCLOSE"));
if(Input::get("column") != 'Total')
{
$col_array = explode('||', Input::get('column'));
$alist->where('c.userstatus', '=',$col_array[0]);
if($col_array[0] != $col_array[1]) {
$alist->where('c.action_code','=',$col_array[1]);
}
}
break;
case 'productivity':
if(Input::get("column") != 'Total')
{
$alist->where('c.resultCode','=',Input::get('column'));
}
break;
case 'nextaction':
$alist->where('c.resultCode','=','PTP');
if(Input::get("column") != 'PTP')
{
$alist->where('c.nextActionCode','=',Input::get('column'));
}
break;
}
if(!$joined) $alist=$alist->leftJoin('records as r', 'c.crm_id', '=', 'r.id');
$alist=$alist->get();
if(Input::get("report") != 'nextaction' || Input::get("column") != 'PU')
$reporthead=array(
'#'=>'#',
'lan'=>'LAN',
'customerName'=>'Customer Name',
'emi'=>'EMI',
'pos'=>'POS',
//'#'=>'OD Days',
'bounceCharge'=>'Bounce Charge',
//'penalMTD'=>'Penal Charges',
'overdueAmount'=>'OD Amount',
'product'=>'Product',
'number'=>'Mobile',
'duedate'=>'Due Date',
//'reasonForLastBounce'=>'Last Bounce',
'residenceAddress'=>'Residence Address',
//'altphone1'=>'Residence Phone No.',
'officeAddress'=>'Office Address',
//'altphone2'=>'Office Phone No.',
//'pickup_address_type'=>'Pickup Address Type',
//'pickup_address'=>'Pickup Address',
//'pickup_address_phone'=>'Pickup Address Phone No.',
'lastMonthPaymentAmount'=>'Last Month Payment Amount',
'lastMonthPaymentDate'=>'Last Month Payment Date',
'installmentAmountOverdue'=>'Installment OD Amount',
'user_id'=>'Telecaller',
//'ptp_amt'=>'PTP Amount',
'nextActionDateTime'=>'PTP Date',
//'payment_mode'=>'Payment Mode',
'depositer_name'=>'Depositer Name',
);
else
$reporthead=array(
'pickup_collection_date'=>'Date of PU',//cc
'pickup_collection_time'=>'PU Time',//cc
'user_id'=>'Agent Name',//cc
'state'=>'State',//re
'location'=>'City',//re
'product'=>'Prod Type',//re
'lan'=>'LAN',//re
'customerName'=>'Customer Name',//re
'pickup_contact_person_name'=>'PU Contact Person',//cc
'pickup_contact_person_mobile'=>'Contact Person #',//cc
'pos'=>'POS',//re
'pickup_emi_amount'=>'EMI Amount',//cc
'pickup_bnp_amount'=>'B&P Amount',//cc
'pi_total'=>'Total PU Amt',//Cal from cc
'pickup_payment_mode'=>'Payment Mode',//cc
'pickup_address'=>'PU Address',//cc
);
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$index_count = 0;
if(Input::get("report") != 'nextaction' || Input::get("column") != 'PU')
$headerRow = $reporthead;
else
$headerRow = array_merge($reporthead,
array('vendor_name' =>'Vendor Name',
'vendor_id' =>'Vendor ID',
'coallocated_id'=>'Coallocated Id',
'fos_name' =>'Fos Name',
'receipt_no' =>'Receipt No.',
'receipt_date' =>'Receipt Date',
'receipt_amt' =>'Receipt Amt',
'vpayment_mode' =>'Mode of Payment',
'cheque_dd_date'=>'Cheque/DD Date',
'cheque_dd' =>'Cheque/DD #',
'drawn_on_bank' =>'Drawn on Bank',
'vendor_remarks'=>'Remarks'
));
foreach($headerRow AS $key => $val){
$colstr=PHPExcel_Cell::stringFromColumnIndex($index_count);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $val);
$index_count++;
}
foreach($alist as $aline)
{
$row = $baseRow++;
$index_count = 0;
$col = 0;
foreach($reporthead AS $key => $val){
$sr_no = $row-1;
switch ($key) {
case '#': $cellval = $sr_no; break;
case 'user_id': $cellval = $userarr[$aline->user_id]->telecaller; break;
case 'pickup_collection_date':
$cellval = ($aline->pickup_collection_date != '0000-00-00 00:00:00') ?
date('Y-m-d', strtotime($aline->pickup_collection_date)) : '0000-00-00'; break;
case 'pickup_collection_time':
$cellval = date('H:i:s', strtotime($aline->pickup_collection_date)); break;
case 'pi_total': $cellval = $aline->pickup_emi_amount+$aline->pickup_bnp_amount; break;
default: $cellval = $aline->$key; break;
}
$colstr=PHPExcel_Cell::stringFromColumnIndex($index_count);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $cellval);
$index_count++;
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Breakup.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
?>