forked from goautodial/v4.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
callrecordings.php
636 lines (563 loc) · 23 KB
/
callrecordings.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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
<?php
/**
* @file callrecordings.php
* @brief Display call recordings
* @copyright Copyright (c) 2018 GOautodial Inc.
* @author Demian Lizandro A. Biscocho
* @author Alexander Jim H. Abenoja
*
* @par <b>License</b>:
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
require_once('./php/UIHandler.php');
require_once('./php/APIHandler.php');
require_once('./php/CRMDefaults.php');
require_once('./php/LanguageHandler.php');
include('./php/Session.php');
$ui = \creamy\UIHandler::getInstance();
$api = \creamy\APIHandler::getInstance();
$lh = \creamy\LanguageHandler::getInstance();
$user = \creamy\CreamyUser::currentUser();
$perm = $api->goGetPermissions('recordings');
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php $lh->translateText("call_recordings"); ?></title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php
print $ui->standardizedThemeCSS();
print $ui->creamyThemeCSS();
print $ui->dataTablesTheme();
?>
<!-- Bootstrap Player -->
<link href="css/bootstrap-player.css" rel="stylesheet" type="text/css" />
<!-- Datetime picker -->
<link rel="stylesheet" src="js/dashboard/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css">
<!-- Date Picker -->
<script type="text/javascript" src="js/dashboard/eonasdan-bootstrap-datetimepicker/build/js/moment.js"></script>
<script type="text/javascript" src="js/dashboard/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
<!-- CHOSEN-->
<link rel="stylesheet" src="js/dashboard/chosen_v1.2.0/chosen.min.css">
<style>
/*
* CUSTOM CSS for disable function
*/
.c-checkbox input[type=checkbox]:disabled + span,
.c-radio input[type=checkbox]:disabled + span,
.c-checkbox input[type=radio]:disabled + span,
.c-radio input[type=radio]:disabled + span {
border-color: none !important;
background-color: none !important;
}
.c-checkbox input[type=checkbox]:checked + span,
.c-radio input[type=checkbox]:checked + span,
.c-checkbox input[type=radio]:checked + span,
.c-radio input[type=radio]:checked + span
{
border-color: #3f51b5 !important;
background-color: #3f51b5 !important;
}
</style>
</head>
<?php print $ui->creamyBody(); ?>
<div class="wrapper">
<!-- header logo: style can be found in header.less -->
<?php print $ui->creamyHeader($user); ?>
<!-- Left side column. contains the logo and sidebar -->
<?php print $ui->getSidebar($user->getUserId(), $user->getUserName(), $user->getUserRole(), $user->getUserAvatar()); ?>
<!-- Right side column. Contains the navbar and content of the page -->
<aside class="right-side content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header content-heading">
<h1>
<?php $lh->translateText("call_recordings"); ?>
<small><?php $lh->translateText("call_recordings"); ?></small>
</h1>
<ol class="breadcrumb">
<li><a href="./index.php"><i class="fa fa-phone"></i> <?php $lh->translateText("home"); ?></a></li>
<li><?php $lh->translateText("telephony"); ?></li>
<li class="active"><?php $lh->translateText("call_recordings"); ?>
</ol>
</section>
<!-- Main content -->
<section class="content">
<?php
if ($perm->recordings_display !== 'N') {
$callrecs = $api->API_getCallRecordingList();
//var_dump($callrecs);
?>
<div class="row">
<div class="col-lg-9">
<div class="form-group mb-xl">
<div class="has-clear">
<input type="text" placeholder="Search Phone Number, First or Last Name" id="search" class="form-control mb">
<span class="form-control-clear fa fa-close form-control-feedback"></span>
</div>
<div class="clearfix">
<button type="button" class="pull-left btn btn-default" id="search_button"> <?php $lh->translateText("search"); ?></button>
<div class="pull-right">
<label class="checkbox-inline c-checkbox" for="search_recordings">
<input id="search_recordings" name="table_filter" type="checkbox" checked disabled>
<span class="fa fa-check"></span><?php $lh->translateText("recordings"); ?>
</label>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-body">
<div class="callrecordings_div">
<!-- Call Recordings panel tab -->
<legend><?php $lh->translateText("call_recordings"); ?></legend>
<!--==== Call Recordings ====-->
<table class="table table-striped table-bordered table-hover" id="table_callrecordings">
<thead>
<tr>
<th nowrap><?php $lh->translateText("date"); ?></th>
<th nowrap class='hide-on-low'><?php $lh->translateText("customer"); ?></th>
<th nowrap class='hide-on-low'><?php $lh->translateText("phone_number"); ?></th>
<th nowrap class='hide-on-medium hide-on-low'><?php $lh->translateText("agent"); ?></th>
<th nowrap class='hide-on-medium hide-on-low'><?php $lh->translateText("duration"); ?></th>
<th nowrap><?php $lh->translateText("action"); ?></th>
</tr>
</thead>
<tbody>
<?php
for($i=0;$i < count($callrecs->uniqueid);$i++){
$details = "<strong>".$lh->translationFor("phone")."</strong>: <i>".$callrecs->phone_number[$i]."</i><br/>";
$details .= "<strong>".$lh->translationFor("agent")."</strong>: <i>".$callrecs->users[$i]."</i><br/>";
$details .= "<strong>".$lh->translationFor("date")."</strong>: <i>".date("M.d,Y h:i A", strtotime($callrecs->end_last_local_call_time[$i]))."</i><br/>";
$d1 = strtotime($callrecs->start_last_local_call_time[$i]);
$d2 = strtotime($callrecs->end_last_local_call_time[$i]);
$diff = abs($d2 - $d1);
$action_Call = $ui->getUserActionMenuForCallRecording($callrecs->uniqueid[$i], $callrecs->location[$i], $details);
?>
<tr>
<td nowrap><?php echo date("M.d,Y h:i A", strtotime($callrecs->end_last_local_call_time[$i]));?></td>
<td nowrap class='hide-on-low'><?php echo $callrecs->full_name[$i];?></td>
<td nowrap class='hide-on-low'><?php echo $callrecs->phone_number[$i];?></td>
<td nowrap class='hide-on-medium hide-on-low'><?php echo $callrecs->users[$i];?></td>
<td nowrap class='hide-on-medium hide-on-low'><?php echo gmdate('H:i:s', $diff); ?></td>
<td nowrap><?php echo $action_Call;?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div><!-- /.body -->
</div><!-- /.panel -->
</div><!-- /.col-lg-9 -->
<?php
$agents = $api->API_getAllUsers();
?>
<div class="col-lg-3">
<h3 class="m0 pb-lg"><?php $lh->translateText("filters"); ?></h3>
<form id="search_form">
<div class="form-group">
<label><?php $lh->translateText("add_filters"); ?>:</label>
<div class="mb">
<div class="add_callrecording_filters">
<select multiple="multiple" class="select2-3 form-control add_filters2" style="width:100%;">
<option value="filter_agent" class="contacts_filters" ><?php $lh->translateText("agent"); ?> </option>
</select>
</div>
</div>
</div>
<!-- CALL RECORDINGS FILTER -->
<div class="all_callrecording_filters">
<div class="callrecordings_filter_div">
<div class="agent_filter_div" style="display:none;">
<div class="form-group">
<label><?php $lh->translateText("agent"); ?>: </label>
<div class="mb">
<select name="agent_filter" id="agent_filter" class="form-control">
<option value=""> <?php $lh->translateText("all_agents"); ?> </option>
<?php
for($i=0; $i < count($agents->user_id);$i++){
echo '<option value="'.$agents->user[$i].'"> '.$agents->user[$i].' - '.$agents->full_name[$i].' </option>';
}
?>
</select>
</div>
</div>
</div>
<div class="form-group">
<label>Start Date:</label>
<div class="form-group">
<div class='input-group date' id='datetimepicker3'>
<input type='text' class="form-control" id="start_filterdate" placeholder="MM/DD/YYYY"/>
<span class="input-group-addon">
<!-- <span class="glyphicon glyphicon-calendar"></span>-->
<span class="fa fa-calendar"></span>
</span>
</div>
</div>
</div>
<div class="form-group">
<label>End Date:</label>
<div class="form-group">
<div class='input-group date' id='datetimepicker4'>
<input type='text' class="form-control" id="end_filterdate" placeholder="MM/DD/YYYY" value="<?php echo date("m/d/Y H:i:s");?>"/>
<span class="input-group-addon">
<!-- <span class="glyphicon glyphicon-calendar"></span>-->
<span class="fa fa-calendar"></span>
</span>
</div>
</div>
</div>
</div>
</div>
<fieldset>
<!--
<div class="campaign_filter_div" style="display:none;">
<div class="form-group">
<label>Campaign: </label>
<div class="mb">
<select name="campaign_filter" class="form-control">
<?php
/*
for($i=0; $i < count($campaign->campaign_id);$i++){
echo "<option value='".$campaign->campaign_id[$i]."'> ".$campaign->campaign_name[$i]." </option>";
}
*/
?>
</select>
</div>
</div>
</div>
-->
</fieldset>
</form>
<!--<button type="button" class="pull-left btn btn-default" id="search_button">Apply</button>-->
</div><!-- ./filters -->
</div><!-- /. row -->
<?php
} else {
print $ui->calloutErrorMessage($lh->translationFor("you_dont_have_permission"));
}
?>
</section><!-- /.content -->
</aside><!-- /.right-side -->
<?php print $ui->getRightSidebar($user->getUserId(), $user->getUserName(), $user->getUserAvatar()); ?>
</div><!-- ./wrapper -->
<!-- Modal -->
<div id="call-playback-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"><b><?php $lh->translateText("call_recording_playback"); ?></b></h4>
</div>
<div class="modal-body">
<center class="mt"><em class="fa fa-music fa-5x"></em></center>
<div class="row mt mb">
<center><span class="voice-details"></span></center>
</div>
<br/>
<div class="audio-player" style="width:100%"></div>
<!-- <audio controls>
<source src="http://www.w3schools.com/html/horse.ogg" type="audio/ogg" />
<source src="http://www.w3schools.com/html/horse.mp3" type="audio/mpeg" />
<a href="http://www.w3schools.com/html/horse.mp3">horse</a>
</audio> -->
</div>
<div class="modal-footer">
<a href="" class="btn btn-primary download-audio-file" download><?php $lh->translateText("download_file"); ?></a>
<button type="button" class="btn btn-default" data-dismiss="modal"><?php $lh->translateText("close"); ?></button>
</div>
</div>
<!-- End of modal content -->
</div>
</div>
<!-- End of modal -->
<?php print $ui->standardizedThemeJS();?>
<!-- CHOSEN-->
<script src="js/dashboard/chosen_v1.2.0/chosen.jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('body').on('keypress', '#search', function(args) {
if (args.keyCode == 13) {
$("#search_button").click();
return false;
}
});
var init_callrecs_table = $('#table_callrecordings').DataTable({
"bDestroy" : true
});
// initialize multiple selecting
$('.select2-3').select2({ theme: "bootstrap" });
$.fn.select2.defaults.set( "theme", "bootstrap" );
// limits checkboxes to single selecting
$("input:checkbox").on('click', function() {
var $box = $(this);
if ($box.is(":checked")) {
var group = "input:checkbox[name='" + $box.attr("name") + "']";
$(group).prop("checked", false);
$box.prop("checked", true);
} else {
$box.prop("checked", false);
}
});
/****
** Change between Contacts and Recordings
****/
// shows call recordings datatable if Recordings tickbox is checked
$(document).on('change','#search_recordings',function() {
$("#search_recordings").prop("disabled", true);
if($('#search_recordings').is(":checked")){
$(".callrecordings_div").show(); // show recordings table
$(".callrecordings_filter_div").show(); // show recording filter
$(".all_callrecording_filters").show(); // show filters
$(".add_callrecording_filters").show(); // enable add filter
}else{
$(".callrecordings_div").hide();
$(".all_callrecording_filters").hide();
$(".add_callrecording_filters").hide(); // disable add filter
}
});
/***
** Add Filters
***/
// add filters
$(".add_filters2").change(function(){
$(".agent_filter_div").fadeIn("slow")[ $.inArray('filter_agent', $(this).val()) >= 0 ? 'show' : 'hide' ]();
}).change();
/****
** Call Recording filters
****/
// ---- DATETIME PICKER INITIALIZATION
$('#datetimepicker3').datetimepicker({
icons: {
time: "fa fa-clock-o",
date: "fa fa-calendar",
up: "fa fa-arrow-up",
down: "fa fa-arrow-down"
}
});
$('#datetimepicker4').datetimepicker({
useCurrent: false,
icons: {
time: "fa fa-clock-o",
date: "fa fa-calendar",
up: "fa fa-arrow-up",
down: "fa fa-arrow-down"
}
});
// ---- DATE FILTERS
$("#datetimepicker3").on("dp.change", function(e) {
$('#datetimepicker4').data("DateTimePicker").minDate(e.date);
if($('#search').val() == ""){
$('#search_button').attr("disabled", false);
$('#search_button').text('<?php $lh->translateText("searching"); ?>');
}else{
$('#search_button').text('<?php $lh->translateText("searching"); ?>');
$('#search_button').attr("disabled", true);
}
if($('#agent_filter').is(':visible')) {
var agent_filter_val = $('#agent_filter').val();
}else{
var agent_filter_val = "";
}
var start_filterdate_val = $('#start_filterdate').val();
var end_filterdate_val = $('#end_filterdate').val();
$.ajax({
url: "filter_callrecs.php",
type: 'POST',
data: {
search_recordings : $('#search').val(),
start_filterdate : start_filterdate_val,
end_filterdate : end_filterdate_val,
agent_filter : agent_filter_val
},
success: function(data) {
$('#search_button').text('<?php $lh->translateText("search"); ?>');
$('#search_button').attr("disabled", false)
console.log(data);
if(data != ""){
$('#table_callrecordings').html(data);
$('#table_callrecordings').DataTable({
"bDestroy" : true
});
}else{
init_callrecs_table.fnClearTable();
}
}
});
});
$("#datetimepicker4").on("dp.change", function(e) {
$('#datetimepicker3').data("DateTimePicker").maxDate(e.date);
if($('#search').val() == ""){
$('#search_button').attr("disabled", false);
$('#search_button').text('<?php $lh->translateText("searching"); ?>');
}else{
$('#search_button').text('<?php $lh->translateText("searching"); ?>');
$('#search_button').attr("disabled", true);
}
if($('#agent_filter').is(':visible')) {
var agent_filter_val = $('#agent_filter').val();
}else{
var agent_filter_val = "";
}
var start_filterdate_val = $('#start_filterdate').val();
var end_filterdate_val = $('#end_filterdate').val();
$.ajax({
url: "filter_callrecs.php",
type: 'POST',
data: {
search_recordings : $('#search').val(),
start_filterdate : start_filterdate_val,
end_filterdate : end_filterdate_val,
agent_filter : agent_filter_val
},
success: function(data) {
$('#search_button').text('<?php $lh->translateText("search"); ?>');
$('#search_button').attr("disabled", false)
console.log(data);
if(data != ""){
$('#table_callrecordings').html(data);
$('#table_callrecordings').DataTable({
"bDestroy" : true
});
}else{
init_callrecs_table.fnClearTable();
}
}
});
});
// AGENT FILTER
$(document).on('change','#agent_filter',function() {
if($('#search').val() == ""){
$('#search_button').attr("disabled", false);
$('#search_button').text('<?php $lh->translateText("searching"); ?>');
}else{
$('#search_button').text('<?php $lh->translateText("searching"); ?>');
$('#search_button').attr("disabled", true);
}
if($('#agent_filter').is(':visible')) {
if($('#agent_filter').is(':visible')) {
var agent_filter_val = $('#agent_filter').val();
}else{
var agent_filter_val = "";
}
}else{
var agent_filter_val = "";
}
var start_filterdate_val = $('#start_filterdate').val();
var end_filterdate_val = $('#end_filterdate').val();
$.ajax({
url: "filter_callrecs.php",
type: 'POST',
data: {
search_recordings : $('#search').val(),
start_filterdate : start_filterdate_val,
end_filterdate : end_filterdate_val,
agent_filter : agent_filter_val
},
success: function(data) {
$('#search_button').text('<?php $lh->translateText("search"); ?>');
$('#search_button').attr("disabled", false)
console.log(data);
if(data != ""){
$('#table_callrecordings').html(data);
$('#table_callrecordings').DataTable({
"bDestroy" : true
});
}else{
init_callrecs_table.fnClearTable();
}
}
});
});
/****
** Search function
****/
$(document).on('click','#search_button',function() {
//init_contacts_table.destroy();
if($('#search').val() == ""){
$('#search_button').attr("disabled", false);
$('#search_button').text('<?php $lh->translateText("searching"); ?>');
}else{
$('#search_button').text('<?php $lh->translateText("searching"); ?>');
$('#search_button').attr("disabled", true);
}
if($('#search_recordings').is(":checked")){
var start_filterdate_val = $('#start_filterdate').val();
var end_filterdate_val = $('#end_filterdate').val();
if($('#agent_filter').is(':visible')) {
var agent_filter_val = $('#agent_filter').val();
}else{
var agent_filter_val = "";
}
$.ajax({
url: "search.php",
type: 'POST',
data: {
search_recordings : $('#search').val(),
start_filterdate : start_filterdate_val,
end_filterdate : end_filterdate_val,
agent_filter : agent_filter_val
},
success: function(data) {
$('#search_button').text('<?php $lh->translateText("search"); ?>');
$('#search_button').attr("disabled", false);
console.log(data);
if(data != ""){
$('#table_callrecordings').html(data);
$('#table_callrecordings').DataTable({
"bDestroy" : true
});
}else{
init_callrecs_table.fnClearTable();
}
}
});
}
});
/*****
** For playing Call Recordings
*****/
$(document).on('click','.play_audio',function() {
var audioFile = $(this).attr('data-location');
//audioFile = audioFile.replace("http", "https");
//console.log(audioFile);
var voicedetails = "";
var sourceFile = '<audio class="audio_file" controls style="width:100%">';
sourceFile += '<source src="'+ audioFile +'" type="audio/mpeg" download="true"/>';
sourceFile += '</audio>';
if(audioFile === ""){
voicedetails = "Recording is being processed... Please wait a few minutes and try again.";
$('.download-audio-file').attr('disabled', true);
} else{
voicedetails = $(this).attr('data-details');
$('.download-audio-file').attr('href', audioFile);
$('.audio-player').html(sourceFile);
}
$('.voice-details').html(voicedetails);
goAvatar._init(goOptions);
$('#call-playback-modal').modal('show');
var aud = $('.audio_file').get(0);
aud.play();
});
$('#call-playback-modal').on('hidden.bs.modal', function () {
var aud = $('.audio_file').get(0);
aud.pause();
});
});
</script>
<?php print $ui->creamyFooter();?>
</body>
</html>