-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfbpagezones.php
278 lines (243 loc) · 7.33 KB
/
fbpagezones.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
<?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();
/*
* NOTE:
* Page needs to be updated to operate over AJAX and API Calls
*
* Christopher Fikes
* 03/05/2017
*/
//Functions for query
function pullZones(){
//Begin Session
session_start();
//GET UUID
$UUID = $_SESSION["domain_uuid"];
try {
//Connect to DB
$fusionBellDB = new PDO("sqlite:$UUID.db");
//Pull Settings
$Result = $fusionBellDB->query("SELECT * FROM zones ORDER BY ZoneName ASC;");
if(count($Result,0) != 0) {
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";
foreach($Result as $row){
$ZoneName = $row['ZoneName'];
$ZoneValue = $row['ZoneValue'];
//Check for special form control needs
switch($ZoneName) {
//Protect All Tone from Deletion
case 'All Tone' :
echo '<tr><td width="20%" class="vncell" style="text-align: left;">' . $ZoneName . '</td><td colspan="2" class="row_style1"><input type="text" class="form-control" name="'. $ZoneName . '" value ="' . $ZoneValue . '"/></td></tr>';
break;
default:
echo '<tr><td width="20%" class="vncell" style="text-align: left;">' . $ZoneName . '</td><td class="row_style1"><input type="text" class="form-control" name="'. $ZoneName . '" value ="' . $ZoneValue . '"/></td><td width="5%"><a class="btn btndark" onclick="delZone(\'' . $ZoneName . '\');">Delete</a></td></tr>';
break;
}
}
echo "</table>";
echo "</br><a class='btn btndark' id='savebtn' onclick='saveZones();'>Save Settings</a>";
}
}
//Issues connecting
catch (PDOException $e) {
print 'Exception : ' . $e->getMessage();
}
}
//show the content
require_once "resources/header.php";
$document['title'] = $text['title-fusionbells'];
?>
<?php
include "includes.php";
echo '<link rel="stylesheet" type="text/css" href="css/overides.css">';
?>
<?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='#newZoneModal'> New Zone</a></li>
<!--<li role="separator" class="divider"></li>-->
</ul>
</li>
<?php navMenuClose(); ?>
<!--
//header
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";
echo "<tr>\n";
echo "<td width='50%'>\n";
echo "<b>Fusion Bells Zones</b>";
echo "<br><br>";
echo "</td>\n";
echo "<td width='50%' align='right'>\n";
echo "<a href='fusionbells.php' class='btn btndark'>Dashboard</a> ";
echo "<a href='fbsettings.php' class='btn btndark'>Settings</a> ";
echo "<a data-toggle='modal' data-target='#newZoneModal' class='btn btndark'>New Zone</a> ";
echo "<a href='fbzonebox.php' class='btn btndark'>ZoneBox</a> ";
echo "</td></tr>";
echo "</table>";
-->
<?php
pullZones();
?>
<!--
New Zone Modal
Christopher Fikes
05/10/2017
-->
<div class="modal fade" id="newZoneModal" 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 Zone</h4>
</div>
<div class="modal-body">
<table class="table table-condensed table-borderless">
<th>Zone Name</th><th>Zone Address</td>
<tr><td><input class="form-control" type="text" id="newZoneName"></td><td><input class="form-control" type="text" id="newZoneValue"></td></tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btndark" onclick='createNewZone();'>Create New Zone</button>
</div>
</div>
</div>
</div>
<script>
/*
* Save Settings through API.
*
* Christopher Fikes
* 03/03/2017
*/
function saveZones(){
var zoneCount = $('.form-control').length;
zoneCount = zoneCount-2;
console.log("Zone Count " + zoneCount);
var i = 0;
$('.form-control').each(function(){
var zoneName = $(this).attr("name");
var zoneValue = $(this).val();
console.log(zoneName + " " + zoneValue);
if( $(this).val() != "" ) {
$("#savebtn").html("Saving Zones. . .");
$("#savebtn").addClass("disabled");
$.ajax({
'method' : "POST",
'url' : "../fusionbells/api.php",
'context' : document.body,
'dataType' : 'json',
'data' : { "call" : "savezone", "zoneName" : zoneName, "zoneValue" : zoneValue},
'success' : function (data) {
console.log(data);
if( data.msg = "complete") {
i++;
if ( zoneCount == i ) {
//Reactivat Button
$("#savebtn").removeClass("disabled");
$("#savebtn").html("Save Zones");
}
}
}
}).done(function(){
//Nothing
});
}
});
}
/*
* Create Zone through API.
*
* Christopher Fikes
* 05/10/2017
*/
function createNewZone(){
var zoneName = $("#newZoneName").val();
var zoneValue = $("#newZoneValue").val();
console.log(zoneName + " " + zoneValue);
$.ajax({
'method' : "POST",
'url' : "../fusionbells/api.php",
'context' : document.body,
'dataType' : 'json',
'data' : { "call" : "newzone", "zoneName" : zoneName, "zoneValue" : zoneValue},
'success' : function (data) {
console.log(data);
if( data.msg = "complete") {
location.reload();
}
}
}).done(function(){
//Nothing
});
}
/*
* Delete Zone through API.
*
* Christopher Fikes
* 05/10/2017
*/
function delZone(zoneName){
console.log(zoneName);
$.ajax({
'method' : "POST",
'url' : "../fusionbells/api.php",
'context' : document.body,
'dataType' : 'json',
'data' : { "call" : "delzone", "zonename" : zoneName},
'success' : function (data) {
console.log(data);
if( data.msg = "complete") {
location.reload();
}
}
}).done(function(){
//Nothing
});
}
</script>
<?php
/*
* Integration piece into Fusion PBX
* Contributor(s):
* Mark J Crane <[email protected]>
*/
require_once "resources/footer.php";
?>