-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfbscheduleedit.php
583 lines (520 loc) · 18.4 KB
/
fbscheduleedit.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
<?php
/*
* Project Name: FusionBells for FusionPBX
*
* Description: Multicast Bell Notification for
* education environments. Uses FFMPEG for transcoding
* and network delivery.
*
* Requirements: FusionPBX, SQLite and Multicast network
* configuration.
*
* Developer: FikesMedia.com
* Contact: [email protected]
* Copyright: Copyright 2017 FikesMedia All Right Reserved
*/
/*
* Integration piece into Fusion PBX
* Contributor(s):
* Mark J Crane <[email protected]>
*/
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('system_status_sofia_status')
|| permission_exists('system_status_sofia_status_profile')
|| if_group("superadmin")) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//show the content
require_once "resources/header.php";
$document['title'] = $text['title-fusionbells'];
//FB Includes
require_once "includes.php";
?>
<link rel='stylesheet prefetch' href='css/fullcalendar.min.css'>
<link rel="stylesheet" type="text/css" href="css/overides.css">
<style>
.fc-event {
margin: 5px 0px;
padding: 0px 5px;
line-height: 25px;
height: 25px;
overflow: hidden;
}
.fusionbellcont {
margin:20px;
}
#tips {
margin-top: 20px;
}
#external-events{
max-height:300px;
padding-right: 10px;
overflow-y: scroll;
overflow-x: hidden !important;
}
.table-borderless tbody tr td,
.table-borderless tbody tr th,
.table-borderless thead tr th,
.table-borderless thead tr td,
.table-borderless tfoot tr th,
.table-borderless tfoot tr td {
border: none;
}
</style>
<?php navMenu(); ?>
<!-- Actions on this page -->
<li class="dropdown">
<a class="dropdown-toggle text-left" data-toggle="dropdown" href="#">
<span class="glyphicon glyphicon-cog" title="Actions"></span>
<span class="hidden-sm" style="margin-left: 5px;">Actions</span>
</a>
<ul class="dropdown-menu">
<li><a data-toggle="modal" data-target="#newScheduleModal"> Add Schedule</a></li>
<!--<li role="separator" class="divider"></li>-->
</ul>
</li>
<?php navMenuClose(); ?>
<!--
<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='50%'><b>Schedule Editor</b><br><br></td>
<td width='50%' align='right'>
<a href='fusionbells.php' class='btn btndark'>Dashboard</a>
<a href='fbschedule.php' class='btn btndark'>Schedule Calendar</a>
<a href='fbsettings.php' class='btn btndark'>Settings</a>
<a data-toggle="modal" data-target="#newScheduleModal" class='btn btndark'>Add Schedule</a>
</td>
</tr>
</table>
-->
<div class="row">
<div class="col-md-2">
<div class="row">
<h4>Schedules</h4>
<div id='external-events'>
<div id='external-events-listing'>
<div class='fc-event' schedule="Default">Default</div>
</div>
</div>
</div>
<div class="row">
<div id="tips">
<p>Tip: Select a schedule to view and modify.</p>
</div>
</div>
</div>
<div class="col-md-10">
<h4 id="currentSchedule">No Schedule Selected</h4>
<table class="table table-borderless">
<tr><td>
<a type="button" class="btn btndark" aria-label="Left Align" data-toggle="modal" data-target="#newBellModal">
<span class="glyphicon glyphicon-bell" aria-hidden="true"></span>
New Bell
</a>
<a type="button" class="btn btndark" aria-label="Left Align" data-toggle="modal" data-target="#delScheduleModal">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
Delete Schedule
</a>
</td></tr>
</table>
<table name="thisSchedule" id="thisSchedule" class="table table-hover">
<thead>
<th class="col-xs-3">Time</th><th>Tone</th><th>Zone</th>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<!--
New Bell Modal
Christopher Fikes
03/03/2017
-->
<div class="modal fade" id="newBellModal" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="gridSystemModalLabel">Add New Bell</h4>
</div>
<div class="modal-body">
<div class="row">
<table class="table table-condensed table-borderless">
<th class="col-xs-3">Hour</th><th class="col-xs-3">Minute</th><th>Ring Tone</th><th>Zone</th>
<tr>
<td><input class="form-control" id="hour" type="text" value="00" name="hour"></td>
<td><input class="form-control" id="minute" type="text" value="00" name="minute"></td>
<td><select class="form-control" id="tone"><?php selectTone(); ?></select></td>
<td><select class="form-control" id="zone"><?php selectZone(); ?></select></td>
</tr>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btndark" data-dismiss="modal" onclick="addRow();">Add</button>
</div>
</div>
</div>
</div>
<!--
Delete Bell Modal
Christopher Fikes
03/03/2017
-->
<div class="modal fade" id="delBellModal" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="gridSystemModalLabel">Delete Bell</h4>
</div>
<div class="modal-body">
<!--<form class="form-inline">-->
<div class="row">
<table class="table table-condensed table-borderless">
<th class="col-xs-3">Time</th><th>Ring Tone</th><th>Zone</th>
<tr>
<td><input class="form-control" type="text" id="delmodaltime" disabled></td>
<td><input class="form-control" type="text" id="delmodaltone" disabled></td>
<td><input class="form-control" type="text" id="delmodalzone" disabled></td>
</tr>
</table>
</div>
<!--</form>-->
</div>
<div class="modal-footer">
<button type="button" class="btn btndark" data-dismiss="modal" onclick='delRow($("#delmodaltime").val(), $("#delmodalzone").val());'>Delete Bell</button>
</div>
</div>
</div>
</div>
<!--
New Schedule Modal
Christopher Fikes
03/03/2017
-->
<div class="modal fade" id="newScheduleModal" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="gridSystemModalLabel">Create New Schedule</h4>
</div>
<div class="modal-body">
<table class="table table-condensed table-borderless">
<th>Schedule Name</th>
<tr><td><input class="form-control" type="text" id="newScheduleName"></td></tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btndark" onclick='createNewSchedule();'>Create New Schedule</button>
</div>
</div>
</div>
</div>
<!--
Delete Schedule Modal
Christopher Fikes
03/03/2017
-->
<div class="modal fade" id="delScheduleModal" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="gridSystemModalLabel">Delete Schedule</h4>
</div>
<div class="modal-body">
<h3>Confirm Deletion?</h3>
</div>
<div class="modal-footer">
<button type="button" class="btn btndark" onclick='deleteSchedule();'>Delete Schedule</button>
</div>
</div>
</div>
</div>
<!-- Touch Spinner -->
<script src="js/jquery.bootstrap-touchspin.js"></script>
<link href="css/jquery.bootstrap-touchspin.css" rel="stylesheet">
<script>
/*
* Sorts Tables based on Time.
*
* Christopher Fikes
* 03/03/2017
*/
function sortTable(){
var rows = $('#thisSchedule tbody tr').get();
rows.sort(function(a, b) {
var A = $(a).children('td').eq(0).text().toUpperCase();
var B = $(b).children('td').eq(0).text().toUpperCase();
if(A < B) { return -1; }
if(A > B) { return 1; }
return 0;
});
$.each(rows, function(index, row) {
console.log(row);
$('#thisSchedule').children('tbody').append(row);
});
console.log("Table Sorted");
}
/*
* Adds row from user input into table.
*
* Christopher Fikes
* 03/03/2017
*/
function addRow(){
//Get Values from form
var hour = $("#hour").val();
var minute = $("#minute").val();
//Check length of tome for DB formating
if(hour.length < 2) {
hour = "0" + hour;
}
if( minute.length < 2) {
minute = "0" + minute;
}
//Setup Variables for row creation
var sentTime = hour+":"+minute;
var sentTone = $("#tone").val();
var sentZone = $("#zone").val();
var sentNewBell = newBell(sentTime,sentTone,sentZone);
//Create row
row = "<tr id=\"" + hour + ":" + minute + "\" tone=\"" + $("#tone").val() + "\" zone=\"" + $("#zone").val() + "\"><td>" + hour + ":" + minute + "</td><td>" + $("#tone").val() + "</td><td>" + $("#zone").val() + "</td></tr>";
$('#thisSchedule').children('tbody').append(row);
//Sort entries after new added
sortTable();
//Close Modal and reset modal values
$('#newBellModal').modal('hide');
$("#hour").val("0");
$("#minute").val("0");
$("#tone").val("");
$("#zone").val("");
}
/*
* Deletes row from table.
*
* Christopher Fikes
* 03/03/2017
*/
function delRow(rowid,zone){
var row = document.getElementById(rowid);
var del = deleteBell(rowid,zone);
row.parentNode.removeChild(row);
}
/*
* Loads entries for specified schedule
*
* Christopher Fikes
* 03/03/2017
*/
function loadScheduleList(schedule) {
$('#thisSchedule').children('tbody').html("");
//Grab from DB over AJAX JSON schedule
$.ajax({
'method' : "POST",
'url' : "../fusionbells/api.php",
'context' : document.body,
'dataType' : 'json',
'data' : { "call" : "readschedule", "schedule" : schedule },
'success' : function (data) {
console.log(data);
$.each(data, function() {
//Not Used, but in here . . .
var working = this.Time.split(':');
var hour = working[0];
var minute = working[1];
var row = "<tr id=\"" + this.Time + "\" tone=\"" + this.Tone + "\" zone=\"" + this.Zone + "\"><td>" + this.Time + "</td><td>" + this.Tone + "</td><td>" + this.Zone + "</td></tr>";
$('#thisSchedule').children('tbody').append(row);
});
}
}).done(function(){
console.log("DONE");
});
}
/*
* List of Schedules to choose from
*
* Christopher Fikes
* 03/03/2017
*/
function loadSchedulesList(schedule) {
$('#external-events-listing').html("");
//Grab from DB over AJAX Json listing of Schedules containing bell times.
$.ajax({
'method' : "POST",
'url' : "../fusionbells/api.php",
'context' : document.body,
'dataType' : 'json',
'data' : { "call" : "readschedules" },
'success' : function (data) {
//Create DIV objects in DOM from received data
$.each(data, function() {
var row = "<div class='fc-event' schedule='"+this.Schedule+"'>"+this.Schedule+"</div>";
$('#external-events-listing').append(row);
});
}
}).done(function(){
console.log("Loaded All Schedules");
});
}
/*
* Create NEW schedule containing default bell
*
* Christopher Fikes
* 03/03/2017
*/
function createNewSchedule() {
//Grab value from user input
var name = $("#newScheduleName").val();
console.log(name);
//Send information to API over AJAX
$.ajax({
'method' : "POST",
'url' : "../fusionbells/api.php",
'context' : document.body,
'dataType' : 'json',
'data' : { "call" : "newschedule" , "schedulename" : name },
'success' : function (data) {
//On Success close modal and reload page to flush
$('#newScheduleModal').modal('hide');
location.reload();
}
}).done(function(){
//Nothing
});
}
/*
* Deletes schedule and all calendar events
*
* Christopher Fikes
* 03/03/2017
*/
function deleteSchedule() {
//Grab name of currently selected schedule
var name = $("#currentSchedule").html();
console.log(name);
//Send request of deletion to API over AJAX
$.ajax({
'method' : "POST",
'url' : "../fusionbells/api.php",
'context' : document.body,
'dataType' : 'json',
'data' : { "call" : "delschedule" , "schedulename" : name },
'success' : function (data) {
//Close Modal and refresh page to flush
$('#delScheduleModal').modal('hide');
location.reload();
}
}).done(function(){
//Nothing
});
}
/*
* Deletes selected bell from current schedule
*
* Christopher Fikes
* 03/03/2017
*/
function deleteBell(time,zone) {
var name = $("#currentSchedule").html();
//Make Request to API with AJAX for deletion
$.ajax({
'method' : "POST",
'url' : "../fusionbells/api.php",
'context' : document.body,
'dataType' : 'json',
'data' : { "call" : "delbell" , "schedulename" : name ,"time" : time,"zone" : zone},
'success' : function (data) {
//Console log return
console.log(data);
}
}).done(function(){
});
}
/*
* Adds new bell to current schedule
*
* Christopher Fikes
* 03/03/2017
*/
function newBell(time,tone,zone) {
//Currently selected schedule
var name = $("#currentSchedule").html();
//MAke request to API over AJAX for new bell creation
$.ajax({
'method' : "POST",
'url' : "../fusionbells/api.php",
'context' : document.body,
'dataType' : 'json',
'data' : { "call" : "newbell" , "schedulename" : name ,"time" : time, "tone" : tone, "zone" : zone},
'success' : function (data) {
//Console log return
console.log(data);
}
}).done(function(){
//Nothing
});
}
/*
* Monitor page for table row click events
*
* Christopher Fikes
* 03/03/2017
*/
$(document).on( "click", "#thisSchedule tr", function() {
$("#delmodaltime").val(this.getAttribute("id"));
$("#delmodaltone").val(this.getAttribute("tone"));
$("#delmodalzone").val(this.getAttribute("zone"));
$('#delBellModal').modal('show');
});
/*
* Monitor page for schedule selection
*
* Christopher Fikes
* 03/03/2017
*/
$(document).on( "click", ".fc-event", function() {
loadScheduleList(this.getAttribute("schedule"));
$("#currentSchedule").html(this.getAttribute("schedule"));
});
/*
* Setup touchspin controls for time selection
*
* Christopher Fikes
* 03/03/2017
*/
$("input[name='hour']").TouchSpin({
min: 0,
max: 23,
stepinterval: 1,
verticalbuttons: true
});
$("input[name='minute']").TouchSpin({
min: 0,
max: 59,
stepinterval: 1,
verticalbuttons: true
});
//Initial request for schedules to be loaded
loadSchedulesList();
</script>
<?php
/*
* Integration piece into Fusion PBX
* Contributor(s):
* Mark J Crane <[email protected]>
*/
require_once "resources/footer.php";
?>