-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
421 lines (400 loc) · 15.5 KB
/
index.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
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<?php
require_once 'functions.php';
if(false === checkLicense()){
header('location:verify.php');
}
?>
<html>
<head>
<meta charset="utf-8">
<title> Yeastar Report Scheduler</title>
<link href="assets/css/style.css" rel="stylesheet" type="text/css">
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css">
<script src="assets/js/jquery-3.1.0.min.js" type="text/javascript"></script>
<script src="assets/js/bootstrap.min.js" type="text/javascript"></script>
</head>
<body>
<div class="content">
<div class="col-md-3 border-full">
<h3>Yeastar Report scheduler</h3><button class="btn btn-primary newcreatebtn" onclick="newcreate()">create new report</button>
<h4></h4>
<input type="text" id="searchschedule" class="form-control" onkeypress="searchschedule(this.value)" onkeyup="searchschedule(this.value)" onkeydown="searchschedule(this.value)" placeholder="Search...">
<div style="width: 100%;height: 84%;overflow: auto;">
<ul class="list-group" id="userschedule">
<li class="list-group-item">no schedule</li>
</ul>
</div>
</div>
<div class="col-md-9 border-full">
<div class="col-md-12">
<div class="row">
<form class="form-horizontal">
<div class="col-md-10">
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-5">Report Name:</div>
<div class="col-sm-7">
<input type="text" class="form-control" name="name" id="name" placeholder="Name...">
<input type="hidden" class="form-control" name="iid" id="iid">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-5">Receiver Email:</div>
<div class="col-sm-7">
<input type="email" class="form-control" name="email" id="email" placeholder="Email...">
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="row">
<!-- save sending message via email -->
<div class="col-md-12">
<h4></h4>
<div class="col-md-10">
<form class="form-horizontal">
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-5">Date:</div>
<div class="col-sm-7">
<select id="timefrom" name="timefrom" class="form-control">
<option value="Day">Daily</option>
<option value="Week">Weekly</option>
<option value="Month">Monthly</option>
</select>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-5">Report Time:</div>
<div class="col-sm-7">
<input type="time" id="timeto" name="timeto" class="form-control" value=<?php echo date('H:i:s'); ?>>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-5">Call From:</div>
<div class="col-sm-7">
<input type="text" id="callfrom" name="callfrom" class="form-control">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-5">Call To:</div>
<div class="col-sm-7">
<input type="text" id="callto" name="callto" class="form-control">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-7">Call Duration more than(s):</div>
<div class="col-sm-5">
<input type="number" id="callduration" name="callduration" class="form-control">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-7">Talk Duration more than(s):</div>
<div class="col-sm-5">
<input type="number" id="talkduration" name="talkduration" class="form-control">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-5">Status:</div>
<div class="col-sm-7">
<select class="form-control" id="status" name="status">
<option>All</option>
<option>Answered</option>
<option>No Answer</option>
<option>Busy</option>
<option>Failed</option>
<option>Voicemail</option>
</select>
</div>
</div>
</div>
<div class="col-md-12">
<h4><a href="#demo" data-toggle="collapse"><i class="fa fa-angle-down">Advanced Options</i></a></h4>
<div id="demo" class="collapse">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-5">Trunk:</div>
<div class="col-sm-7">
<select class="form-control" id="drunk" name="drunk">
<option value="">All</option>
<option value="DIGIT1">DIGIT1 (E1)</option>
<option value="GSM2-1">GSM2-1(GSM)</option>
<option value="FXO2-3">FXO2-3(FXO)</option>
<option value="FXO2-4">FXO2-4(FXO)</option>
<option value="BRI2-5">BRI2-5(BRI)</option>
<option value="BRI2-6">BRI2-6(BRI)</option>
</select>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-5">Communication Type:</div>
<div class="col-sm-7">
<select class="form-control" id="communicationtype" name="communicationtype">
<option value="">All</option>
<option value="Inbound">Inbound</option>
<option value="Outbount">Outbount</option>
<option value="Internal">Internal</option>
<!-- <option>Multisite Interconnect</option> -->
<!-- <option>Callback</option> -->
<option value="Transfer">Transfer</option>
<!-- <option>Warning</option> -->
</select>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-5">PIN Code:</div>
<div class="col-sm-7">
<input type="number" class="form-control" id="pincode" name="pincode">
</div>
</div>
</div>
<div class="col-md-6">
<!-- <div class="form-group">
<div class="col-sm-7"><label class="checkbox-inline"><input type="checkbox" class="form-check-input" id="number_fuzzy" name="number_fuzzy">Number Fuzzy Search<span class="badge">!</span></label></div>
<div class="col-sm-5">
</div>
</div> -->
</div>
</div>
</div>
<div style="margin-left: 60%;">
<button class="btn btn-info" type="button" onclick="saveschedule()">Save Schedule</button>
<button class="btn btn-info" type="button" onclick="searchtable()">Search for current day</button>
</div>
</div>
</form>
</div>
<div class="col-md-2"></div>
</div>
</div>
<div class="col-md-12">
<div>
<table class="table" style="display:block">
<thead>
<tr>
<th style="width: 5%">No</th>
<th style="width: 10%">Time</th>
<th style="width: 10%">Call From</th>
<th style="width: 10%">Call To</th>
<th style="width: 10%">Call Duration</th>
<th style="width: 10%">Talk Duration</th>
<th style='width: 10%'>Status</th>
</tr>
</thead>
<tbody style="height: 43%;display:block;overflow-y:scroll" class="list-group" id="callstable">
</tbody>
</table>
</div>
</div>
</div>
</div>
<script>
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("userschedule").innerHTML = this.responseText;
}
};
xhttp.open("POST", "scheduleread.php", true);
xhttp.send();
//schedule search function
function searchschedule(val) {
var filter, ul, li, span, i, txtValue;
filter = val.toUpperCase();
ul = document.getElementById("userschedule");
li = ul.getElementsByTagName("li");
for (i = 0; i < li.length; i++) {
span = li[i].getElementsByTagName("span")[0];
txtValue = span.textContent || span.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
li[i].style.display = "";
} else {
li[i].style.display = "none";
}
}
}
//schedule remove function
function scheduleremove(id, name) {
if (confirm("Do you want to remove schedule " + name + "?")) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("sche_" + name).remove();
newcreate();
readtable();
alert(this.responseText);
}
};
xhttp.open("GET", "scheduleremove.php?id=" + id, true);
xhttp.send();
} else {
return;
}
}
function selectschedule(id) {
$('li.list-group-item').removeClass('active');
$('li[iid="sche_'+id+'"]').addClass('active');
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
res = JSON.parse(this.responseText);
results = res[0];
$("#iid").val(id);
$("#name").val(results['name']);
$("#email").val(results['email']);
$("#timefrom").val(results['timefrom']);
$("#timeto").val(results['timeto']);
$("#callfrom").val(results['callfrom']);
$("#callto").val(results['callto']);
$("#callduration").val(results['callduration']);
$("#talkduration").val(results['talkduration']);
$("#status").val(results['status']);
$("#drunk").val(results['drunk']);
$("#communicationtype").val(results['communicationtype']);
$("#pincode").val(results['pincode']);
$("#number_fuzzy").prop("checked", parseInt(results['number_fuzzy']) ? true : false);
searchtable();
}
};
xhttp.open("GET", "selectschedule.php?id=" + id, true);
xhttp.send();
}
//save schedule
function saveschedule() {
if ($('#email').val() == "") {
alert("the 'receiver email' item should be provided!");
return;
}
if ($('#name').val() == "") {
alert("the 'Report name' item should be provided!");
return;
}
var data = {
id: $("#iid").val(),
email: $("#email").val(),
name: $("#name").val(),
timefrom: $("#timefrom").val(),
timeto: $("#timeto").val(),
callfrom: $("#callfrom").val(),
callto: $("#callto").val(),
callduration: $("#callduration").val(),
talkduration: $("#talkduration").val(),
status: $("#status").val(),
drunk: $("#drunk").val(),
communicationtype: $("#communicationtype").val(),
pincode: $("#pincode").val(),
number_fuzzy: $("#number_fuzzy:checked").val() ? 1 : 0,
}
$.ajax({
type: "POST",
url: "./saveschedule.php",
data: data,
// contentType: "application/json; charset=utf-8",
success: function(data) {
alert(data);
window.location.reload();
},
error: function(e) {
console.log(e.message);
}
})
}
function newcreate() {
$("#iid").val("");
$("#email").val("");
$("#name").val("");
$("#timefrom").val("Day");
$("#timeto").val("");
$("#callfrom").val("");
$("#callto").val("");
$("#callduration").val("");
$("#talkduration").val("");
$("#status").val("All");
$("#drunk").val("All");
$("#communicationtype").val("All");
$("#pincode").val("");
readtable()
}
function readtable() {
var txt = "";
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("callstable").innerHTML = this.responseText;
// myObj = JSON.parse(this.responseText);
}
};
xmlhttp.open("POST", "readtable.php", true);
xmlhttp.send();
}
function searchtable() {
var data = {
timefrom: $("#timefrom").val(),
timeto: $("#timeto").val(),
callfrom: $("#callfrom").val(),
callto: $("#callto").val(),
callduration: $("#callduration").val(),
talkduration: $("#talkduration").val(),
status: ($("#status").val()) == 'All' ? "" : $("#status").val(),
drunk: $("#drunk").val() == 'All' ? "" : $("#drunk").val(),
communicationtype: $("#communicationtype").val() == 'All' ? "" : $("#communicationtype").val(),
pincode: $("#pincode").val(),
// number_fuzzy: $("#number_fuzzy:checked").val() ? 1 : 0,
};
$.ajax({
type: "POST",
// dataType: "json",
url: "./readsearchtable.php",
data: data,
// contentType: "application/json; charset=utf-8",
success: function(data) {
// console.log(JSON.parse(data));
document.getElementById("callstable").innerHTML = data;
},
error: function(e) {
console.log(e.message);
}
});
}
function checkSchedule(){
$.ajax({
url : 'sendmail.php',
success: function(){
setTimeout(()=>{
checkSchedule()
}, 5000)
},
error: function(){
setTimeout(()=>{
checkSchedule()
}, 5000)
}
})
}
checkSchedule();
readtable();
</script>
</body>
</html>