head.blade.php
2.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
<?php
use App\Models\CRMCall;
use App\Models\CRMCallArchive;
use App\Models\User;
use App\Jobs\KHRMSLib;
use App\Models\Record;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
$timeoffset = $dashboarduser->timezone;
$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=Record::whereHas('calls', function ($query) use ($logdate, $logdateto) {
$query->where('created_at','>=',date("Y-m-d H:i:s",$logdate))
->where('created_at','<=',date("Y-m-d H:i:s",$logdateto));
})->where('usr_id','!=',0);
$alist=$alist->where('modified','>=',date("Y-m-d H:i:s",$logdate))
->where('modified','<=',date("Y-m-d H:i:s",$logdateto));
$displayAdv = 'none';
if(!in_array('All', $campaign)) {
$displayAdv = 'block';
$alist =$alist->whereIn('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('usr_id',$uidlist);
}
else {
$allusers=$allusers->get();
foreach($allusers as $tuser)
{
$userarr[$tuser->id] = $tuser;
}
}