d3e9f98da3ffe42ac20e00e446bdb8a723e1bece.php
2.8 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
<?php
if(Input::has("dllogxls"))
{
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");
$ulists=DB::select(DB::raw("SELECT MONTH(crmcalls_archive.created_at) AS month, users.username, users.usertype, users.status, COUNT(DISTINCT EXTRACT(DAY FROM crmcalls_archive.created_at)) AS Number_of_Days, COUNT(DISTINCT crmcalls_archive.created_at) AS Number_of_calls FROM `users` INNER JOIN crmcalls_archive on users.id=crmcalls_archive.user_id WHERE crmcalls_archive.created_at >= '".date("Y-m-d H:i:s",$logdate)."' AND crmcalls_archive.created_at < '".date("Y-m-d H:i:s",$logtodate)."' GROUP BY users.id, MONTH(crmcalls_archive.created_at) ORDER BY MONTH(crmcalls_archive.created_at) DESC"));
$reportArr = array();
foreach($ulists as $ulist)
{
$reportArr[] = (array)$ulist;
}
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="seatcount.csv";');
header('Cache-Control: max-age=0');
$headers = ['month','username','usertype','status','Number_of_Days','Number_of_calls'];
$f = fopen('php://output','w');
fputcsv($f, $headers);
foreach($reportArr as $arr)
{
fputcsv($f, $arr);
}
return ;
}
else
{
?>
<div class="row">
<div class="col-md-12">
<div class=innerAll>
<fieldset style='margin-bottom:2%'>
<label>From:</label>
<input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d"); ?>' onchange='callLogReloadFun("");' />
<label>To:</label>
<input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d"); ?>' onchange='callLogReloadFun("");' />
</fieldset>
<fieldset style='margin-bottom:2%'>
<span style="color: #fb6e52;">To Download seat count click on following button.</span><br><br>
<input type=button class='btn btn-green' onclick="sendReq();" value="Download">
<div style='clear:both;height: 10px;'></div>
</fieldset>
</div>
</div>
<div style='clear:both;'></div>
</div>
<script>
$('#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); ?>'});
function sendReq()
{
// var postdata="dwnld=download";
// doAjax("record?action=seatcount",postdata,"employeeresult","esajaxMutex","esvarajax");
window.open('setting/seatcount?dllogxls=1&logdate='+$("#modfrom").val()+'&logtodate='+$("#modto").val());return false;
// window.open('record/seatcount?dwnld=download');
// return false;
}
</script>
<?php
}