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
| <!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Таблица Vlan</title>
<meta charset="utf-8" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="css/bootstrap.min.css">
<link type="text/css" href="css/all.css" rel="stylesheet">
<!--<link rel="stylesheet" href="assets/bootstrap.min.css" />-->
<link href="css/rackhost.css" rel="stylesheet" type="text/css" />
<link href="css/select2.min.css" rel="stylesheet" />
<script src="assets/jquery.min.js"></script>
<script src="assets/bootstrap.min.js"></script>
<script src="js/select2.min.js"></script>
<link rel="stylesheet" href="css/simplePagination.css" />
<script src="js/jquery.simplePagination.js"></script>
<!--<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>-->
<script src="js/rackhost.js" type="text/javascript"></script>
<style>
body
{
margin:0;
padding:0;
background-color:#f1f1f1;
color:#000;
}
.box
{
width:1270px;
padding:20px;
background-color:#fff;
border:1px solid #ccc;
border-radius:5px;
margin-top:100px;
}
input[type="text"],
input[type="password"],
select,
textarea
{
width: 100%;
}
</style>
</head>
<body>
<!-- Site Wrapper Start -->
<div class="siteWrapper">
<!-- Site Header -->
<?php
require_once("header.php");
?>
</div>
</div>
<!-- Content Slider -->
<div class="contentSlider">
</div>
<!-- Content Wrapper -->
<div class="contentWrapper">
<div class="outerShadow">
</div>
<div class="innerShadow">
</div>
<div class="center clearfix">
<!-- Additional clearfix necessary for non floated objects -->
<div class="clearfix">
</div>
<h2>Перечень <span>Vlan</span></h2>
<div class="column small">
<h3 class="iconMediumNetwork">Vlan </h3>
<form id="myForm_Vlan">
<select class="js-select2" name="city" placeholder="Выберите город" id="IdVlan" style="width:150px";>
<?php
//Выводим перечень Vlan
while ($row=mysqli_fetch_array($NVlan))
{
print "<option value=".$row['NumVlan'].">";
print $row['NumVlan'];
echo ("</option>");
}
?>
</select>
</form>
</div>
<div class="column small">
<h3 class="iconMediumNetwork">IP<span>-подсеть</span> </h3>
<form id="myForm1">
<select class="js-select2" name="city" placeholder="Выберите город" id="idip"style="width:250px">
<?php
//Выводим перечень Vlan
while ($row=mysqli_fetch_array($IP))
{
print "<option value=".$row['Subnet'].">";
print $row['Subnet'];
echo ("</option>");
}
?>
</select>
</form>
</div>
<div class="column small last">
<h3 class="iconMediumNetwork">Контур </h3>
<form id="myForm_Kontur">
<select class="js-select2" name="city" placeholder="Выберите город" id="Kontur"style="width:150px">
<?php
//Выводим перечень Vlan
while ($row=mysqli_fetch_array($Kontur))
{
print "<option value=".$row['Kontur'].">";
print $row['Kontur'];
echo ("</option>");
}
?>
</select>
</form>
</div>
</div>
<!--Скрипты для обработки-->
<script>
$(document).ready(function() {
$('.js-select2').select2({
placeholder: "Выберите город",
maximumSelectionLength: 2,
language: "ru"
});
});
</script>
<!--Вывод по номеру Vlan-->
<script>
$(document).ready(function(){
$('#IdVlan').change(function(){
$.ajax({
type: "POST",
url: "control/control_vlan.php",
data: "NumVlan="+$("#IdVlan").val(),
success: function(html){
$("#tableWrapper").html(html);
}
});
return false;
});
});
</script>
<!--Вывод по подсети-->
<script>
$(document).ready(function(){
$('#idip').change(function(){
$.ajax({
type: "POST",
url: "control/control_vlan.php",
data: "idip="+$("#idip").val(),
success: function(html){
$("#tableWrapper").html(html);
}
});
return false;
});
});
</script>
<!--Вывод по Контуру-->
<script>
$(document).ready(function(){
$('#Kontur').change(function(){
$.ajax({
type: "POST",
url: "control/control_vlan.php",
data: "Kontur="+$("#Kontur").val(),
success: function(html){
$("#tableWrapper").html(html);
}
});
return false;
});
});
</script>
<!--Скрипты для обработки-->
<!--<div class="col mt-1">-->
<?=$success ?>
<!--<button type="button" id="modal_button" class="btn btn-info"><i class="fa fa-user-plus"></i></button>-->
<!-- При нажатии кнопки Добавить запись подгружается модальное окно !-->
<!--</div>-->
<div class="tableWrapper" section id="tableWrapper">
</div>
</div>
<!-- Site Footer -->
<?php
require_once("Footer.php");
?>
<!-- Site Wrapper Ends -->
<!--<div class="modal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-header">
<h2>DDDDD</h2>
<a href="#" class="bnt-close closemodal" aria-hidden="true">×</a>
</div>
<div class="modal-body">
</div>
</div>-->
</body>
</html>
<!-- Модальное окно которое будем использовать для добавления или изменения информации, в данный момент скрыто!-->
<div id="customerModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Добавить запись</h4>
</div>
<div class="modal-body">
<label>Введите Подсеть</label>
<input type="text" name="Subnet" id="Subnet" class="form-control" />
<br />
<label>Введите номер VLAN</label>
<input type="text" name="IPVlan" id="IPVlan" class="form-control" />
<br />
<label>Введите Description</label>
<input type="text" name="Description" id="Description" class="form-control" />
<br />
<label>Введите IP_адрес</label>
<input type="text" name="IPAdress" id="IPAdress" class="form-control" />
<br />
<label>Введите Дата</label>
<input type="text" name="MyDate" id="MyDate" class="form-control" />
<br />
<label>Кто выделил</label>
<input type="text" name="Bywhom" id="Bywhom" class="form-control" value="<?php echo $_SESSION['login']?>"/>
<br />
<label>Контур</label>
<select id="Circuit" name="Circuit">
<?php
$Kontur=mysqli_query($conn, "SELECT distinct Kontur FROM vlan") or die(mysqli_error());
//Выводим перечень Vlan
while ($row=mysqli_fetch_array($Kontur))
{
print "<option value=".$row['Kontur'].">";
print $row['Kontur'];
echo ("</option>");
}
?>
</select>
<br />
<label>Введите коментарий</label>
<input type="text" name="Coment" id="Coment" class="form-control" />
<br />
</div>
<div class="modal-footer">
<input type="hidden" name="customer_id" id="customer_id" />
<input type="submit" name="action" id="action" class="btn btn-success" />
<button type="button" class="btn btn-default" data-dismiss="modal">Отмена</button>
</div>
</div>
</div>
</div>
<script>//Определение текущей даты для вставки в форму
var dt=new Date();
var month = dt.getMonth()+1;
if (month<10) month='0'+month;
var day = dt.getDate();
if (day<10) day='0'+day;
var year = dt.getFullYear();
MyDate.value=day+'.'+month+'.'+year;
</script>
<script>
$(document).ready(function()
{
$('body').on('click', 'td.edit', (function()
{
//находим input внутри элемента с классом ajax и вставляем вместо input его значение
$('.ajax').html($('.ajax input').val());
//удаляем все классы ajax
$('.ajax').removeClass('ajax');
//ячейке присваиваем класс ajax
$(this).addClass('ajax');
//внутри ячейки создаём input и вставляем текст из ячейки в него
$(this).html('<input id="editbox" size="'+ $(this).text().length+'" type="text" value="' + $(this).text() + '" />');
//устанавливаем фокус на созданном элементе
$('#editbox').focus();
}));
//определяем нажатие кнопки на клавиатуре
$('body').on('keydown', 'td.edit', (function(event)
{
//получаем значение класса и разбиваем на массив, отделённый пробелами
//в итоге получаем такой массив — arr[0] = edit, arr[1] = наименование столбца
arr = $(this).attr('class').split( " " );
var feild = arr[1];
//alert(feild);
var opid = feild.split( "_" );
//alert(opid);
var id = $(this).closest('table').attr('id').split(" ");
//проверяем какая была нажата клавиша и если была нажата клавиша Enter (код 13)
if(event.which == 13)
{
//получаем наименование таблицы, в которую будем вносить изменения
var table = $(this).closest('table').attr('id');
//alert(table);
//выполняем ajax запрос методом POST
//var data={action:"updateop", opid:opid[1], opname:opid[0], value:$('.ajax input').val(),table:id[0],id:id[1]}
//alert(data);
//$.post('control/update_ipadd.php',
//{
// action: "updateop",
// opid: opid[1],
// opname: opid[0],
// value:$('.ajax input').val(),
// table:id[0],
// id:id[1]
$.ajax({
method:"POST",
url:"control/update_vlan.php",
data:{action:"updateop", opid:opid[1], opname:opid[0], value:$('.ajax input').val(),table:id[0],id:id[1]},
success:function(data){
$('.ajax').html($('.ajax input').val());
$('.ajax').removeClass('ajax');
}
// } , function(data)
// {
//находим input внутри элемента с классом ajax и вставляем вместо input его значение
// $('.ajax').html($('.ajax input').val());
//удаляем класс ajax
// $('.ajax').removeClass('ajax');
});
}
}));
});
</script>
<!--2021-->
<script>
$(document).ready(function(){
fetchUser(); //Функция подгружает данные после загрузки страницы в тэг <div id="tableWrapper">
function fetchUser()
{
var action = "Load";
$.ajax({
url : "control/control_vlan.php", //Ajax запрос отсылается к "action.php"
method:"POST", //Используем POST метод
data:{action:action}, //пересылаем данные на сервер
success:function(data){
$('#tableWrapper').html(data); //После получения результата отображаем в информацию в тэге <div id="tableWrapper">
}
});
}
//Очищаем поля ввода данных модального окна для заполнения информацией
$('#modal_button').click(function(){
$('#customerModal').modal('show'); //Отображаем модальное окно
$('#Subnet').val('');
$('#IPVlan').val('');
$('.modal-title').text("Добавление новой записи"); //Заголовок модального окна
$('#action').val('Добавить'); //Кнопка добавления модального окна
});
$(document).ready(function(){
$('#action ').click(function(){
var data={
Subnet:$('#Subnet').val(),
IPVlan:$('#IPVlan').val(),
Description:$('#Description').val(),
IPAdress:$('#IPAdress').val(),
MyDate:$('#MyDate').val(),
Bywhom:$('#Bywhom').val(),
Circuit:$('#Circuit').val(),
Coment:$('#Coment').val(),
id:$('#customer_id').val(),
action:$('#action').val(),
}
$.ajax({
method:"POST",
url:"control/control_vlan.php",
data:data,
success: function(data){
//alert(data);
$('#customerModal').modal('hide');
$("#tableWrapper").html(data);
//fetchUser();
}
});
return false;
});
});
//JQuery код для удаления записи без перезагрузки страницы
$(document).on('click', '.delete', function(){
var id = $(this).attr("id");
if(confirm("Вы уверены что хотите удалить эти данные?"))
{
var action="Delete";
$.ajax({
method:"POST",
url:"control/control_vlan.php",
data:{id:id, action:action},
success:function(data)
{
$("#tableWrapper").html(data);
//alert(data);
}
})
}
})
});
</script>
<!--2021-->
<script>
$(document).ready(function(){
$('.pagination').pagination({
items: <?php echo $total_records;?>,
itemsOnPage: <?php echo $limit;?>,
cssStyle: 'light-theme',
currentPage : <?php echo $page;?>,
hrefTextPrefix : 'control_vlan.php?page='
});
});
</script> |