reporthead.blade.php
2.98 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
<?php
use App\Models\CRMCall;
use App\Models\CRMCallArchive;
use App\Models\User;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
$timeoffset = $dashboarduser->timezone; //-330; //$dashboarduser->timezone;\
//$timeoffset = $timeoffset*60;
$timeoffset = 0;
$logtime =(isset($_GET['logtime'])) ? $_GET['logtime'] :9;
$logtimeto =(isset($_GET['logtimeto']))? $_GET['logtimeto']:20;
$logdate =(isset($_GET['logdate'])) ? strtotime($_GET['logdate']." ".$logtime.":00:00")
: strtotime(date("Y-m-d")." 09:00:00");
$logdateto =(isset($_GET['logdateto']))? strtotime($_GET['logdateto']." ".$logtimeto.":00:00")
: strtotime(date("Y-m-d")." 20:00:00");
$campaign =explode('||', (isset($_GET['campaign'])) ? $_GET['campaign'] : "All");
$state =explode('||', (isset($_GET['state'])) ? $_GET['state'] : "All");
$product =explode('||', (isset($_GET['product'])) ? $_GET['product'] : "All");
$bucket =explode('||', (isset($_GET['bucket'])) ? $_GET['bucket'] : "All");
$clientlist =$wakka->clientsReadAccess(); $clientlist; $clientlist[0] = 'All';
$alist=DB::table('crmcalls_archive AS c')->leftJoin('records', 'c.crm_id', '=', 'records.id')->where('c.user_id','!=',0);
$alist=$alist ->where('c.created_at','>=',date("Y-m-d H:i:s",$logdate))
->where('c.created_at','<=',date("Y-m-d H:i:s",$logdateto));
$displayAdv = 'none';
if(!in_array('All', $campaign)) {
$displayAdv = 'block';
$alist =$alist->whereIn('c.client',$campaign);
}
$userarr=array();
$allusers = DB::table('users as u1')->leftjoin('users AS u2', 'u2.username', '=', 'u1.supervisor')
->select('u1.id','u1.username','u1.fullname AS telecaller', 'u2.fullname AS sepervisor');
if($dashboarduser->usertype != 'Admin')
{
$uidlist=array($dashboarduser->id);
$allusers=$allusers->where(function ($query) use($dashboarduser) {
$query->where('u1.supervisor','=',$dashboarduser->username)
->orWhere('u1.lteam2','=',$dashboarduser->username)
->orWhere('u1.lteam','=',$dashboarduser->username);
})->get();
foreach($allusers as $tuser)
{
$uidlist[]=$tuser->id;
$userarr[$tuser->id] = $tuser;
}
$alist=$alist->whereIn('c.user_id',$uidlist);
/*$roclientstr=array();$didlinesstr=array();
if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten;
if(!empty($clientlist))foreach($clientlist as $tclnt)if($tclnt!="")
{
$roclientstr[]="$tclnt";
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
}
$alist=$alist->where(function ($query) use($roclientstr,$uidlist,$didlinesstr){
$query->orWhereIn('c.client',$roclientstr)
->orWhereIn('c.did',$didlinesstr);
});*/
}
else {
$allusers=$allusers->get();
foreach($allusers as $tuser)
{
$userarr[$tuser->id] = $tuser;
}
}