-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpon.php
159 lines (147 loc) · 4.56 KB
/
pon.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
<?php
include ("header.php");
include ("common.php");
include ("dbconnect.php");
include ("navigation.php");
include ("classes/pon_class.php");
include ("classes/snmp_class.php");
if ($user_class < "6")
exit();
$pon_obj = new pon();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// ADD PON PORT
if ($pon_obj->getSubmit() == "ADD") {
if (!empty($pon_obj->getName()) && !empty($pon_obj->getSlot_id()) && !empty($pon_obj->getPort_id()) && !empty($pon_obj->getCards_model_id ())) {
$error = $pon_obj->create_pon();
if (isset($error)) {
echo "<center><div class=\"bg-danger text-white\">" . $error . "</div></center>";
}else{
echo "<center><div class=\"bg-success text-white\">PON Port added Succesfully</div></center>";
}
} else {
echo "<center><div class=\"bg-danger text-white\">ERROR: Name, SLOT_ID, PORT_ID and MODEL_CARD are required fields!</div></center>";
}
}
// EDIT PON
if ($pon_obj->getSubmit() == "EDIT") {
if (!empty($pon_obj->getPon_id()) && !empty($pon_obj->getName()) && !empty($pon_obj->getSlot_id()) && !empty($pon_obj->getPort_id()) && !empty($pon_obj->getCards_model_id ())) {
$error = $pon_obj->edit_pon();
if (isset($error)) {
echo "<center><div class=\"bg-danger text-white\">" . $error . "</div></center>";
}else{
print "<center><div class=\"bg-success text-white\">PON Edited Succesfully</div></center>";
}
} else {
echo "<center><div class=\"bg-danger text-white\">ERROR: Name, SLOT_ID, PORT_ID and MODEL_CARD are required fields! Or you are missing PON_ID!</div></center>";
}
}
// DELETE PON
if ($pon_obj->getSubmit() == "DELETE") {
if (!empty($pon_obj->getPon_id())) {
$error = $pon_obj->delete_pon();
if (isset($error)) {
echo "<center><div class=\"bg-danger text-white\">" . $error . "</div></center>";
}else{
print "<center><div class=\"bg-success text-white\">PON Port Deleted Succesfully</div></center>";
}
} else {
echo "<center><div class=\"bg-danger text-white\">ERROR: PON_ID missing!</div></center>";
}
}
}
?>
<div class="container">
<div class="text-center">
<div class="page-header">
<h2>PON Configuration</h2>
</div>
</div>
<div class="row justify-content-md-center">
<div class="text-center">
<div class="form-group">
<form class="form-inline" action="pon.php" method="post">
<div class="content">
<label for="olt_id">OLT</label>
<select class="form-control" id="select-olt" name="olt">
<option value="" class="rhth">Select OLT</option>
<?php
$rows = $pon_obj->get_from_olt();
foreach ($rows as $row) {
print "<option value=\"" . $row['ID'] ."\">" . $row['NAME'] . "</option>";
}
?>
</select>
<button class="btn btn-basic" type="submit" name="SUBMIT" value="LOAD">LOAD</button>
</div>
</form>
</div>
</div>
</div>
</div>
<?php
if (!empty($pon_obj->getOlt())) {
?>
<div class="container">
<div class="text-center">
<h2>OLT: <?php echo $pon_obj->getOlt_name(); ?></h2>
</div>
<div class=row>
<div class="text-center">
<div class="table-responsive">
<table class="table table-bordered table-condensed table-hover">
<thead>
<tr>
<th>Name</th>
<th>SLOT_ID</th>
<th>PORT_ID</th>
<th>CARDS_MODEL</th>
<th>EDIT</th>
</tr>
</thead>
<tbody>
<?php
$rows = $pon_obj->build_table_pon();
foreach ($rows as $row) {
?>
<tr>
<td><?php echo $row['NAME']; ?></td>
<td><?php echo $row['SLOT_ID']; ?></td>
<td><?php echo $row['PORT_ID']; ?></td>
<td><?php echo $row['CARDS_MODEL_NAME']; ?></td>
<td><button type="button" class="btn btn-default" onClick="getPon('<?php echo $row['ID']; ?>','<?php echo $row['OLT']; ?>');">EDIT</button></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="text-center">
<button type="button" class="btn btn-info" onClick="addPon('<?php echo $pon_obj->getOlt(); ?>');">ADD NEW PON</button>
</div>
</div>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">PON</h4>
</div>
<div class="modal-body" id="modalbody">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>