-
Notifications
You must be signed in to change notification settings - Fork 1
/
Queuelog.class.php
192 lines (174 loc) · 5.47 KB
/
Queuelog.class.php
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
<?php
namespace FreePBX\modules;
use Exception;
use FreePBX\BMO;
use FreePBX\FreePBX_Helpers;
use FreePBX\modules\Queuelog\Traits\QueueLogTrait;
class Queuelog extends FreePBX_Helpers implements BMO
{
use QueueLogTrait;
/** @var BMO */
private $FreePBX = null;
/**
* Queuelog constructor.
*
* @param object $freepbx
* @throws Exception
*/
public function __construct($freepbx = null)
{
if ($freepbx == null) {
throw new Exception("Not given a FreePBX Object");
}
$this->FreePBX = $freepbx;
$this->db = $freepbx->Database;
}
public function install()
{
// TODO: Implement install() method.
}
public function uninstall()
{
// TODO: Implement uninstall() method.
}
/**
* Processes form submission and pre-page actions.
*
* @param string $page Display name
* @return bool
* @throws Exception
*/
public function doConfigPageInit($page)
{
$action = $this->getReq('action', '');
$id = $this->getReq('id', '');
$page = $this->getReq('page', '');
switch ($page) {
case 'answered':
switch ($action) {
case 'add':
return '';
break;
}
break;
}
}
/**
* Adds buttons to the bottom of pages per set conditions
*
* @param array $request $_REQUEST
*
* @return array
*/
public function getActionBar($request)
{
switch($request['display']) {
case 'queuelog':
$buttons = [
'delete' => ['name' => 'delete', 'id' => 'delete', 'value' => _('Excluir'),],
'reset' => ['name' => 'reset', 'id' => 'reset', 'value' => _("Redefinir"),],
'submit' => ['name' => 'submit', 'id' => 'submit', 'value' => _("Enviar"),],
];
if (!isset($request['id']) || trim($request['id']) == '') {
unset($buttons['delete']);
}
if (empty($request['view']) || $request['view'] != 'form') {
$buttons = [];
}
break;
}
return $buttons;
}
/**
* Returns bool permissions for AJAX commands
* https://wiki.freepbx.org/x/XoIzAQ
* @param string $command The ajax command
* @param array $setting ajax settings for this command typically untouched
* @return bool
*/
public function ajaxRequest($command, &$setting) {
//The ajax request
switch ($command) {
case "getJSON":
case "getQueues":
return true;
break;
default:
return false;
}
}
/**
* Handle Ajax request
*
* @return array | bool
*/
public function ajaxHandler()
{
switch($_REQUEST['command']) {
case "getJSON":
$page = !empty($_REQUEST['page']) ? $_REQUEST['page'] : '';
if ('grid' == $_REQUEST['jdata']) {
switch ($page) {
case 'agent_stats':
return $this->getAgentStats($_REQUEST);
break;
case 'queue_stats':
return $this->getQueueStats($_REQUEST);
break;
case 'sla_stats':
return $this->getSlaStats($_REQUEST);
break;
case 'hangup_stats':
return $this->getHangupStats($_REQUEST);
break;
case 'abandoned_stats':
return $this->getAbandonedStats($_REQUEST);
break;
case 'calls_detail':
return $this->getCallsDetail($_REQUEST);
break;
case 'calls_hour':
return $this->getCallsHour($_REQUEST);
break;
}
}
break;
case "getQueues":
return $this->getQueues();
break;
default:
return json_encode(['status' => false, 'message' => _("Solicitação Inválida")]);
}
}
/**
* @param $request $_REQUEST
* @return string
*/
public function getRightNav($request)
{
return load_view(__DIR__."/views/rnav.php",array());
}
/**
* This returns html to the main page
*
* @param $page
* @return string html
*/
public function showPage($page)
{
switch ($page) {
case 'stats':
$content = load_view(__DIR__ . '/views/stats/grid.php');
return load_view(__DIR__.'/views/default.php', ['content' => $content]);
break;
case 'detail':
$content = load_view(__DIR__ . '/views/detail/grid.php');
return load_view(__DIR__.'/views/default.php', ['content' => $content]);
break;
case 'distribution':
$content = load_view(__DIR__ . '/views/distribution/grid.php');
return load_view(__DIR__.'/views/default.php', ['content' => $content]);
break;
}
}
}