This repository has been archived by the owner on Jan 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
provision_specific_add_page2.php
307 lines (269 loc) · 12.1 KB
/
provision_specific_add_page2.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
<?php
if (file_exists("provision_system_config.php"))
{
include_once("provision_system_config.php");
include_once("provision_system_functions.php");
}
else
{
header("Location: provision_install.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<script>
function makeButtonBlink(val) {
document.getElementById("submit_panel_"+val).className = "button-custom";
}
function stopButtonBlink(val) {
document.getElementById("submit_panel_"+val).className = "";
}
</script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="keywords" content="" />
<title><?php echo $provision_soft_title; ?></title>
<!-- ========== CSS Files ========== -->
<link href="css/root.css" rel="stylesheet">
</head>
<body>
<!-- Start Page Loading
<div class="loading"><img src="img/loading.gif" alt="loading-img"></div>
<!-- End Page Loading -->
<!-- START TOP -->
<div id="top" class="clearfix">
<!-- Start App Logo -->
<div class="applogo">
<a href="index.html" class="logo"><?php echo $provision_soft_logo; ?></a>
</div>
<!-- End App Logo -->
<!-- Start Sidebar Show Hide Button -->
<a href="#" class="sidebar-open-button"><i class="fa fa-bars"></i></a>
<a href="#" class="sidebar-open-button-mobile"><i class="fa fa-bars"></i></a>
<!-- End Sidebar Show Hide Button -->
<!-- Start Sidepanel Show-Hide Button -->
<!-- End Sidepanel Show-Hide Button -->
</div>
<!-- END TOP -->
<!-- START SIDEBAR -->
<div class="sidebar clearfix">
<ul class="sidebar-panel nav">
<li class="sidetitle">NAVIGATION</li>
<?php $page=5; include_once("provision_system_navi.php"); ?>
</ul>
</div>
<!-- END SIDEBAR -->
<!-- START CONTENT -->
<div class="content">
<!-- Start Page Header -->
<div class="page-header">
<h1 class="title"><a href="provision_specific.php">Individual Settings</a> > Manage</h1>
<ol class="breadcrumb">
<li class="active">Manage settings on an individual level.</li>
</ol>
</div>
<!-- End Page Header -->
<?php
$this_mac = $_GET['mac_address'];
$chosen_model = $_GET['type'];
//$chosen_group = $_GET['group'];
$chosen_cat = $_GET['cat'];
//Check if exists
$con = connect_mysql();
if ($con)
{
$con->query("USE pvx_provisioner");
//if ($chosen_group==0) {$chosen_group_soft="Any Group";} else {$chosen_group_soft="Group ".$chosen_group;}
echo '<div class="container-widget">';
echo '<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading"><b>'.mac_to_softname($this_mac).'</b><br><br><a href="provision_specific_add.php?mac_address='.$this_mac.'"><-- Back to Sections</a></div>
</div>
</div>
</div>';
//We have our section (category) titles
$q3=$con->query("SELECT * FROM provisioner_device_defaults WHERE device_type=".$chosen_model." AND category_name='".urldecode($chosen_cat)."' ORDER BY slotID");
echo '<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">'.urldecode($chosen_cat).'</div>
<div class="panel-body table-responsive">';
while($a3=$q3->fetch())
{
//<a onclick="swal(\'Inheritence Report\',\'This button will tell you inheritence.\');"><i class="fa fa-level-up"></i></a>
//We have our individual settings. Parse the option first!
//Left Side:
echo '<div class="col-md-6"><a onclick="swal(\''.$a3['setting_name'].'\',\''.$a3['setting_description'].'\');">'.$a3['setting_name'].'</a> <small>('.$a3['setting_variable_name'].')</small></div>';
//Right Side:
echo '<form action="provision_specific_submit_panel.php?type='.$chosen_model.'&mac_address='.$this_mac.'" method="POST" target="feedback_panel_1">';
if ($a3['setting_variable_type']==1) //Dropdown
{
$inherit_string="";
//GET DEFAULT
//$qD=$con->query("SELECT * FROM provisioner_device_defaults WHERE device_type=".$chosen_model." AND setting_variable_name='".$a3['setting_variable_name']."'");
//if ($qD && $qD->rowCount()) {$aD=$qD->fetch(); $defaultValue=$aD['setting_option_1'];} else {$defaultValue="";}
//GET OUR ENTRY
$qE=$con->query("SELECT * FROM provisioner_specific_settings WHERE mac_address='".$this_mac."' AND setting_variable_name='".$a3['setting_variable_name']."'");
if ($qE && $qE->rowCount()>0) {$aE=$qE->fetch(); $myValue=$aE['setting_option_1'];} else {$myValue="";}
if ($myValue==="") {$myValue=$a3['setting_option_1'];}
//SELECT
//Calculate inheritence
$q5 = $con->query("SELECT * FROM provisioner_global_settings WHERE device_type=".$chosen_model." AND device_group=".mac_to_group($this_mac)." AND setting_variable_name='".$a3['setting_variable_name']."'");
if ($q5 && $q5->rowCount()>0)
{
$a5=$q5->fetch();
$inherit_string='<a onclick="swal(\'Inheritance Report\',\'Setting inherited from: \r\n'.device_type_to_name($chosen_model).' > Group '.$this_device_group.' > '.$a3['setting_name'].'\');"><i class="fa fa-level-up"></i></a>'; //Inhereted by THE GROUP
}
else
{
//Check the ALL GROUPS directive
//Check the group
$q6 = $con->query("SELECT * FROM provisioner_global_settings WHERE device_type=".$chosen_model." AND device_group=0 AND setting_variable_name='".$a3['setting_variable_name']."'");
if ($q6 && $q6->rowCount()>0)
{
$a6=$q6->fetch();
$inherit_string='<a onclick="swal(\'Inheritance Report\',\'Setting inherited from: \r\n'.device_type_to_name($chosen_model).' > All Groups > '.$a3['setting_name'].'\');"><i class="fa fa-level-up"></i></a>'; //Inherited by ALL GROUPS
}
}
echo '<div class="col-md-6">
<select name="'.$a3['setting_variable_name'].'" onchange="makeButtonBlink(1);">';
for($i=1;$i<=20;$i+=1)
{
$this_option=$a3['setting_option_'.$i];
$this_option_name=$a3['setting_option_'.$i.'_name'];
if ($this_option_name!="")
{
if ($myValue==$this_option) {echo '<option value="'.$this_option.'" selected>'.$this_option_name.'</option>';} else {echo '<option value="'.$this_option.'">'.$this_option_name.'</option>';}
}
}
echo '</select> '.$inherit_string.'
</div>';
}
elseif ($a3['setting_variable_type']==2) //Text
{
$inherit_string="";
//GET DEFAULT
//$qD=$con->query("SELECT * FROM provisioner_device_defaults WHERE device_type=".$chosen_model." AND setting_variable_name='".$a3['setting_variable_name']."'");
//if ($qD && $qD->rowCount()) {$aD=$qD->fetch(); $defaultValue=$aD['setting_option_1'];} else {$defaultValue="";}
//GET OUR ENTRY
$qE=$con->query("SELECT * FROM provisioner_specific_settings WHERE mac_address='".$this_mac."' AND setting_variable_name='".$a3['setting_variable_name']."'");
if ($qE && $qE->rowCount()>0) {$aE=$qE->fetch(); $myValue=$aE['setting_option_1'];} else {$myValue="";}
if ($myValue==="") {$myValue=$a3['setting_option_1'];}
//FREETYPE
//Calculate our inheritence
$q5 = $con->query("SELECT * FROM provisioner_global_settings WHERE device_type=".$chosen_model." AND device_group=".mac_to_group($this_mac)." AND setting_variable_name='".$a3['setting_variable_name']."'");
if ($q5 && $q5->rowCount()>0)
{
$a5=$q5->fetch();
$inherit_string='<a onclick="swal(\'Inheritance Report\',\'Setting inherited from: \r\n'.device_type_to_name($chosen_model).' > Group '.$this_device_group.' > '.$a3['setting_name'].'\');"><i class="fa fa-level-up"></i></a>'; //Inhereted by THE GROUP
}
else
{
//Check the ALL GROUPS directive
//Check the group
$q6 = $con->query("SELECT * FROM provisioner_global_settings WHERE device_type=".$chosen_model." AND device_group=0 AND setting_variable_name='".$a3['setting_variable_name']."'");
if ($q6 && $q6->rowCount()>0)
{
$a6=$q6->fetch();
$inherit_string='<a onclick="swal(\'Inheritance Report\',\'Setting inherited from: \r\n'.device_type_to_name($chosen_model).' > All Groups > '.$a3['setting_name'].'\');"><i class="fa fa-level-up"></i></a>'; //Inherited by ALL GROUPS
}
}
//Find inherited value
echo '<div class="col-md-6">
<input name="'.$a3['setting_variable_name'].'" value="'.str_replace("!PLUS!", "+", urldecode($myValue)).'" onkeyup="makeButtonBlink(1);" placeholder="'.inherit_specific($chosen_model,$this_mac,$a3['setting_variable_name']).'"> '.$inherit_string.'
</div>';
}
else
{
echo 'Unrecognized Variable Type';
}
echo '<br><hr>';
}
echo '<input type="submit" id="submit_panel_1" value="Save This Panel" style="float:right;" onclick="stopButtonBlink(1);"></form><iframe id="feedback_panel_1" style="border:none; height:40px;"></iframe></div></div></div></div>';
}
echo '</div>';
?>
<!-- //////////////////////////////////////////////////////////////////////////// -->
<!-- START CONTAINER
<div class="container-widget">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">Model/Group Selection</div>
<div class="panel-body table-responsive">
</div>
</div>
</div>
</div>
<BR><BR><BR>
</div>
<!-- END CONTAINER -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<!-- Start Footer -->
<?php include_once("system_footer.php"); ?>
<!-- End Footer -->
</div>
<!-- End Content -->
<!-- ================================================
jQuery Library
================================================ -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<!-- ================================================
Bootstrap Core JavaScript File
================================================ -->
<script src="js/bootstrap/bootstrap.min.js"></script>
<!-- ================================================
Plugin.js - Some Specific JS codes for Plugin Settings
================================================ -->
<script type="text/javascript" src="js/plugins.js"></script>
<!-- ================================================
Bootstrap Select
================================================ -->
<script type="text/javascript" src="js/bootstrap-select/bootstrap-select.js"></script>
<!-- ================================================
Bootstrap Toggle
================================================ -->
<script type="text/javascript" src="js/bootstrap-toggle/bootstrap-toggle.min.js"></script>
<!-- ================================================
Bootstrap WYSIHTML5
================================================ -->
<!-- main file -->
<script type="text/javascript" src="js/bootstrap-wysihtml5/wysihtml5-0.3.0.min.js"></script>
<!-- bootstrap file -->
<script type="text/javascript" src="js/bootstrap-wysihtml5/bootstrap-wysihtml5.js"></script>
<!-- ================================================
Sweet Alert
================================================ -->
<script src="js/sweet-alert/sweet-alert.min.js"></script>
<!-- ================================================
Kode Alert
================================================ -->
<script src="js/kode-alert/main.js"></script>
<!-- ================================================
Gmaps
================================================ -->
<!-- google maps api
<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<!-- main file
<script src="js/gmaps/gmaps.js"></script>
<!-- demo codes
<script src="js/gmaps/gmaps-plugin.js"></script>
<!-- ================================================
jQuery UI
================================================ -->
<script type="text/javascript" src="js/jquery-ui/jquery-ui.min.js"></script>
<!-- ================================================
Data Tables
================================================ -->
<script src="js/datatables/datatables.min.js"></script>
<script>
$(document).ready(function() {
$('#example0').DataTable();
} );
</script>
</body>
</html>