Issues (2963)

includes/html/print-customoid.php (1 issue)

1
<?php
2
3
require_once 'includes/html/modal/new_customoid.inc.php';
4
require_once 'includes/html/modal/delete_customoid.inc.php';
5
6
$no_refresh = true;
7
8
?>
9
10
<div class="row">
11
    <div class="col-sm-12">
12
        <span id="message"></span>
13
    </div>
14
</div>
15
<form method="post" action="" id="oid_form">
16
17
<?php
18
19
echo csrf_field();
20
if (isset($_POST['num_of_rows']) && $_POST['num_of_rows'] > 0) {
21
    $rows = $_POST['rows'];
22
} else {
23
    $rows = 10;
24
}
25
?>
26
27
<div class="table-responsive">
28
  <table class="table table-hover table-condensed" width="100%">
29
    <tr>
30
      <th>Name</th>
31
      <th>OID</th>
32
      <th>Value</th>
33
      <th>Unit</th>
34
      <th colspan="2">Alert Threshold</th>
35
      <th colspan="2">Warning Threshold</th>
36
      <th>Alerts</th>
37
      <th>Passed</th>
38
      <th style="width:86px;">Action</th>
39
    </tr>
40
41
<?php
42
echo '<tr>
43
<td colspan="4">
44
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#create-oid-form" data-device_id="' . $device['device_id'] . '"' . (Auth::user()->hasGlobalAdmin() ? '' : ' disabled') . '><i class="fa fa-plus"></i> Add New OID</button>
0 ignored issues
show
The method hasGlobalAdmin() does not exist on Illuminate\Contracts\Auth\Authenticatable. It seems like you code against a sub-type of Illuminate\Contracts\Auth\Authenticatable such as Illuminate\Foundation\Auth\User. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#create-oid-form" data-device_id="' . $device['device_id'] . '"' . (Auth::user()->/** @scrutinizer ignore-call */ hasGlobalAdmin() ? '' : ' disabled') . '><i class="fa fa-plus"></i> Add New OID</button>
Loading history...
45
</td>
46
<th><small>High</small></th>
47
<th><small>Low</small></th>
48
<th><small>High</small></th>
49
<th><small>Low</small></th>
50
<td></td>
51
<td></td>
52
<td><select name="rows" id="rows" class="form-control input-sm" onChange="updateResults(this);">';
53
54
$num_of_rows_options = [
55
    '10',
56
    '25',
57
    '50',
58
    '100',
59
];
60
foreach ($num_of_rows_options as $option) {
61
    echo "<option value='" . $option . "'" . ($rows == $option ? ' selected' : '') . '>' . $option . '</option>';
62
}
63
64
echo '</select></td>
65
</tr>';
66
67
$query = 'FROM customoids';
68
$where = '';
69
$param = [];
70
if (isset($device['device_id']) && $device['device_id'] > 0) {
71
    $where = 'WHERE (device_id=?)';
72
    $param[] = $device['device_id'];
73
}
74
75
$count = dbFetchCell("SELECT COUNT(*) $query $where", $param);
76
if (isset($_POST['page_num']) && $_POST['page_num'] > 0 && $_POST['page_num'] <= $count) {
77
    $page_num = $_POST['page_num'];
78
} else {
79
    $page_num = 1;
80
}
81
82
$start = (($page_num - 1) * $rows);
83
$full_query = "SELECT * $query $where ORDER BY customoid_descr ASC LIMIT $start,$rows";
84
85
foreach (dbFetchRows($full_query, $param) as $oid) {
86
    echo "<tr class='" . $oid['customoid_id'] . "' id='row_" . $oid['customoid_id'] . "'>";
87
    echo '<td>' . $oid['customoid_descr'] . '</td>';
88
    echo '<td>' . $oid['customoid_oid'] . '</td>';
89
    echo '<td>' . $oid['customoid_current'] . '</td>';
90
    echo '<td>' . $oid['customoid_unit'] . '</td>';
91
    echo '<td>' . $oid['customoid_limit'] . '</td>';
92
    echo '<td>' . $oid['customoid_limit_low'] . '</td>';
93
    echo '<td>' . $oid['customoid_limit_warn'] . '</td>';
94
    echo '<td>' . $oid['customoid_limit_low_warn'] . '</td>';
95
    echo "<td><input id='" . $oid['customoid_id'] . "' type='checkbox' name='alert'" . ($oid['customoid_alert'] ? ' checked' : '') . ' disabled></td>';
96
    echo "<td><input id='" . $oid['customoid_id'] . "' type='checkbox' name='passed'" . ($oid['customoid_passed'] ? ' checked' : '') . ' disabled></td>';
97
    echo '<td>';
98
    echo "<div class='btn-group btn-group-sm' role='group'>";
99
    echo "<button type='button' class='btn btn-primary' data-toggle='modal' data-target='#create-oid-form' data-customoid_id='" . $oid['customoid_id'] . "' name='edit-oid' data-content='' data-container='body'" . (Auth::user()->hasGlobalAdmin() ? '' : ' disabled') . "><i class='fa fa-lg fa-pencil' aria-hidden='true'></i></button>";
100
    echo "<button type='button' class='btn btn-danger' aria-label='Delete' data-toggle='modal' data-target='#delete-oid-form' data-customoid_id='" . $oid['customoid_id'] . "' name='delete-oid' data-content='' data-container='body'><i class='fa fa-lg fa-trash' aria-hidden='true'" . (Auth::user()->hasGlobalAdmin() ? '' : ' disabled') . '></i></button>';
101
    echo '</div>';
102
    echo '</td>';
103
    echo "</tr>\r\n";
104
}//end foreach
105
106
if (($count % $rows) > 0) {
107
    echo '<tr>
108
        <td colspan="11" align="center">' . generate_pagination($count, $rows, $page_num) . '</td>
109
        </tr>';
110
}
111
112
echo '</table>
113
</div>
114
<input type="hidden" name="page_num" id="page_num" value="' . $page_num . '">
115
<input type="hidden" name="num_of_rows" id="num_of_rows" value="' . $rows . '">
116
</form>';
117
118
?>
119
120
<script>
121
122
$("[data-toggle='modal'], [data-toggle='popover']").popover({
123
    trigger: 'hover',
124
        'placement': 'top'
125
});
126
127
function updateResults(rows) {
128
    $('#num_of_rows').val(rows.value);
129
    $('#page_num').val(1);
130
    $('#oid_form').trigger( "submit" );
131
}
132
133
function changePage(page,e) {
134
    e.preventDefault();
135
    $('#page_num').val(page);
136
    $('#oid_form').trigger( "submit" );
137
}
138
139
</script>
140