raicingcustomerreport.blade.php
8.29 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php
use App\Models\CRMCall;
use App\Models\User;
use App\Jobs\KHRMSLib;
use App\Models\SupervisonComments;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
$agents=array();
if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00");
else $logdate=strtotime(date('Y-m-d')." 00:00:00");
if(isset($_GET['logtodate']))$logtodate=strtotime($_GET['logtodate']." 23:59:59");
else $logtodate=strtotime(date('Y-m-d')." 23:59:59");
if(isset($_GET['agents']))
{
$agents[]=$_GET['agents'];
}
else $agents="";
/*$pb_code=implode(",",$agents);
echo "-----".$$pb_code;*/
$userarr=array();$i=1;
$reporthead=array("id","date","pb_name","pb_code","pb_code","pb_landline_contact_no","supervisor_mail_id","group_id","group_id_name","cust_id","cust_name","relationship_with_group_id","cust_id_next","cust_name_next","relationship_with_group_id_next","new_group_addition_to_group","racing_from","supervisor_status","Submit");
if(isset($_GET['agents'])){
print_r($agents);
$reportarray=DB::table('potentialcustomer_details')->select('*')->where('date','>=',date("Y-m-d H:i:s",$logdate))->where('date','<=',date("Y-m-d H:i:s",$logtodate))->whereIn('pb_code',$agents)->get();
}else{
$reportarray=DB::table('potentialcustomer_details')->select('*')->where('date','>=',date("Y-m-d H:i:s",$logdate))->where('date','<=',date("Y-m-d H:i:s",$logtodate))->get();
}
//echo $reportarray;die();
/* $allusers=User::where(function ($query) use($dashboarduser) {
$query->where('supervisor','=',$dashboarduser->username)
->orWhere('lteam2','=',$dashboarduser->username)
->orWhere('lteam','=',$dashboarduser->username);
})->get();
foreach($allusers as $alluser){
$usrData = json_decode($alluser->data);
$usrHRMSData = unserialize($usrData->hrmsdata);
if($usrHRMSData['clientsownerlist']&&$usrHRMSData['clientsownerlist']!='null')
$client[] = $usrHRMSData['clientsownerlist'];
$username[] = $alluser->username;
//print_r($username);
}*/
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++){
if($reporthead[$head]=="date")
$uarr->$reporthead[$head]=date("Y-m-d H:i:s",strtotime($uarr->$reporthead[$head])+330*60);
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr->$reporthead[$head]);
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="PotentialCustomers.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
//echo "<pre><br>".print_r($reportarray)."</pre>";
$highestColumn = sizeof($reporthead);
//echo $highestColumn;
if(count($reportarray)) {
$outhead="<tr>";$outstr="";$id="";
for ($head = 0; $head < $highestColumn; $head++){
$outhead.="<td>".$reporthead[$head]."</td>";
}
$outhead.="</tr>";
foreach($reportarray as $uid=>$uarr)
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head]=="date"){
$uarr->$reporthead[$head]=date("Y-m-d H:i:s",strtotime($uarr->$reporthead[$head])+330*60);
}
if($reporthead[$head]=="id"){
$id=$uarr->$reporthead[$head];
}
if($reporthead[$head]=="supervisor_status"){
$outstr.="<td><select id='".$id."_action_taken'><option value='Pending'>Pending</option><option value='Action Taken'>Action Taken</option><option value='Rejected'>Rejected</option></select></td>";
}else if($reporthead[$head]=="Submit"){
$outstr.="<td><input type='button' id='".$id."_save' value='Save' onclick='updatesupervisorfeedback($id);'></td>";
}else {
$outstr.="<td>".$uarr->$reporthead[$head]."</td>";
}
}
$outstr.="</tr>";
}
}
else {
$outhead.="<tr><td>No Records Found.</td></tr>";
}
?>
<style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style>
<script>
$(document).ready(function()
{
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
</script>
<div class=innerAll>
<h4 style="float:left;width:50%;margin:10px 0;">Racing Customer</h4>
<div style="float:right;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i>Download</button>
</div>
<div style="clear:both"></div>
<hr style="margin-bottom: 5px;">
<div>
Date:From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='statusLogReloadFun("");'/>
To<input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logtodate); ?>' onchange='statusLogReloadFun("");'/>
<!--PB Code:
<select id='usrname' class=select2multi multiple="" style="width: 30%;" > -->
<?php
/*$companyarr=$wakka->LoadAll("select * from hrms_masters where mtype='company'");
foreach($companyarr as $tcompany)
{
$seltxt='';
if(strstr(",".$clientslist.",",",$tcompany[mkey],"))$seltxt='selected="selected"';
echo "<option value='$tcompany[mkey]' $seltxt>$tcompany[mkey]</option>";
}*/
?>
<!-- </select>
<button class="pull-right btn btn-sm btn-default" onclick='statusLogReloadFun("");return false;' title='Search' style='margin-top:-1px'><i class='fa fa-search'></i>Search</button> -->
</div>
<div id=createtaskdiv></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;>
<thead><?php echo $outhead; ?></thead>
<?php echo $outstr; ?>
</table>
</div>
<div id=dialoglog></div>
</div>
<script>
function dlAgentlogXls()
{
window.open('dialer/raicingcustomerreport?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val());return false;
}
function dataString()
{
/*var agents=$('#usrname').val();
var agentsval=[];
if(agents=="" || agents==null){
}else
{
for(i=0;i<agents.length;i++)
{
agentsval[i] = "'" + String(agents[i]) + "'";
}
agentsval=agentsval.join(",");
return 'logdate='+$("#modfrom").val()+'&logdateto='+$("#modto").val()+'&agents='+agentsval;
}*/
return 'logdate='+$("#modfrom").val()+'&logdateto='+$("#modto").val();
}
function statusLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
var searchStr = dataString();
doAjax('dialer/raicingcustomerreport?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function updatesupervisorfeedback(id)
{
var supervisorstatus=$('#'+id+'_action_taken').val();
var postdata='id='+id;
postdata+='&supervisorstatus='+supervisorstatus;
doAjax('racingcustupdate',postdata,'createtaskdiv','ajaxMutex_recSaveData','singlethis','POST');
}
</script>