ona  18.1.1
About: OpenNetAdmin provides a database managed inventory of your IP network (with Web and CLI interface).
  Fossies Dox: ona-18.1.1.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

app_advanced_search.inc.php
Go to the documentation of this file.
1 <?php
2 
3 
4 // We need to build the html drop-down boxes for the
5 // "Custom Attribute", "Device model", "Device type", and "Device manufacturer" fields.
6 global $onadb;
7 
8 
9 // Build subnet type list
10 list($status, $rows, $records) = db_get_records($onadb, 'subnet_types', 'id >= 1', 'display_name');
11 $subnet_type_list = '<option value="">&nbsp;</option>\n';
12 $record['display_name'] = htmlentities($record['display_name']);
13 foreach ($records as $record) {
14  $subnet_type_list .= "<option value=\"{$record['id']}\">{$record['display_name']}</option>\n";
15 }
16 
17 
18 
19 // Set the window title:
20 $window['title'] = "Advanced Search";
21 
22 // Javascript to run after the window is built
23 $window['js'] = <<<EOL
24  /* Put a minimize icon in the title bar */
25  el('{$window_name}_title_r').innerHTML =
26  '&nbsp;<a onClick="toggle_window(\'{$window_name}\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
27  el('{$window_name}_title_r').innerHTML;
28 
29  /* Put a help icon in the title bar */
30  el('{$window_name}_title_r').innerHTML =
31  '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
32  el('{$window_name}_title_r').innerHTML;
33 
34  suggest_setup('hostname', 'suggest_hostname');
35  suggest_setup('domain', 'suggest_domain');
36  suggest_setup('mac', 'suggest_mac');
37  suggest_setup('ip', 'suggest_ip');
38  suggest_setup('ip_thru', 'suggest_ip_thru');
39  suggest_setup('notes', 'suggest_notes');
40  suggest_setup('ip_subnet', 'suggest_ip_subnet');
41  suggest_setup('ip_subnet_thru', 'suggest_ip_subnet_thru');
42  suggest_setup('subnet', 'suggest_subnet');
43  suggest_setup('location', 'suggest_location');
44  el('host_search_form').onsubmit = function() { return false; };
45  el('subnet_search_form').onsubmit = function() { return false; };
46 
47  /* Setup the Quick Find location icon */
48  var _button = el('qf_location_{$window_name}');
49  _button.style.cursor = 'pointer';
50  _button.onclick =
51  function(ev) {
52  if (!ev) ev = event;
53  /* Create the popup div */
54  wwTT(this, ev,
55  'id', 'tt_qf_location_{$window_name}',
56  'type', 'static',
57  'direction', 'south',
58  'delay', 0,
59  'styleClass', 'wwTT_qf',
60  'javascript',
61  "xajax_window_submit('tooltips', '" +
62  "tooltip=>qf_location," +
63  "id=>tt_qf_location_{$window_name}," +
64  "input_id=>qf_location_{$window_name}');"
65  );
66  };
67 
69 
70 // Define the window's inner html
71 $window['html'] = <<<EOL
72 
73  <!-- Tab for selecting a subnet or host search -->
74  <table width="100%" cellspacing="0" border="0" cellpadding="0" style="margin-top: 0.2em">
75  <tr>
76  <td id="host_search_tab" nowrap="true" class="padding"
77  style="cursor: pointer; {$style['borderT']}; {$style['borderB']}; {$style['borderR']}; background-color: {$color['window_tab_active_bg']};"
78  onClick="el('subnet_search').style.display = 'none'; el('subnet_search_tab').style.backgroundColor = '{$color['window_tab_inactive_bg']}';
79  el('host_search').style.display = 'block'; el('host_search_tab').style.backgroundColor = '{$color['window_tab_active_bg']}';">
80  Host search</td>
81 
82  <td id="subnet_search_tab" nowrap="true" class="padding"
83  style="cursor: pointer; {$style['borderT']}; {$style['borderB']}; {$style['borderR']};"
84  onClick="el('host_search').style.display = 'none'; el('host_search_tab').style.backgroundColor = '{$color['window_tab_inactive_bg']}';
85  el('subnet_search').style.display = 'block'; el('subnet_search_tab').style.backgroundColor = '{$color['window_tab_active_bg']}';">
86  Subnet search</td>
87 
88  <td width="80%" class="padding" style="{$style['borderB']};">&nbsp;</td>
89  </tr>
90  </table>
91 
92 
93  <!-- Host Search Tab -->
94  <form id="host_search_form">
95  <input type="hidden" name="search_form_id" value="host_search_form">
96  <table style="background-color: {$color['window_content_bg']};" id="host_search" width="100%" cellspacing="0" border="0" cellpadding="0">
97 
98  <tr>
99  <td align="right" class="asearch-line">
100  <u>H</u>ostname
101  </td>
102  <td align="left" class="asearch-line">
103  <input id="hostname" name="hostname" type="text" class="edit" size="35" accesskey="h" />
104  <div id="suggest_hostname" class="suggest"></div>
105  </td>
106  </tr>
107 
108  <tr>
109  <td align="right" class="asearch-line">
110  Subdomain (<u>z</u>one)
111  </td>
112  <td align="left" class="asearch-line">
113  <input id="domain" name="domain" type="text" class="edit" size="35" accesskey="z" />
114  <div id="suggest_domain" class="suggest"></div>
115  </td>
116  </tr>
117 
118  <tr>
119  <td align="right" class="asearch-line">
120  <u>M</u>AC
121  </td>
122  <td align="left" class="asearch-line">
123  <input id="mac" name="mac" type="text" class="edit" size="17" accesskey="m" />
124  <div id="suggest_mac" class="suggest"></div>
125  </td>
126  </tr>
127 
128  <tr>
129  <td align="right" class="asearch-line">
130  <u>I</u>P Address
131  </td>
132  <td align="left" class="asearch-line" nowrap="true">
133  <input id="ip" name="ip" type="text" class="edit" size="15" accesskey="i" />
134  <div id="suggest_ip" class="suggest"></div>
135  thru
136  <input id="ip_thru" name="ip_thru" class="edit" type="text" size="15">
137  <div id="suggest_ip_thru" class="suggest"></div>
138  </td>
139  </tr>
140 
141  <tr>
142  <td align="right" class="asearch-line">
143  <u>N</u>otes
144  </td>
145  <td align="left" class="asearch-line">
146  <input id="notes" name="notes" type="text" class="edit" size="17" accesskey="n" />
147  <div id="suggest_notes" class="suggest"></div>
148  </td>
149  </tr>
150 
151  <tr>
152  <td align="right" class="asearch-line">
153  <u>L</u>ocation Ref
154  </td>
155  <td align="left" class="asearch-line">
156  <input id="location" class="edit" type="text" name="location" size="8" accesskey="l" />
157  <!--<span id="qf_location_{$window_name}"><img src="{$images}/silk/find.png" border="0"/></span>-->
158  <div id="suggest_location" class="suggest"></div>
159  </td>
160  </tr>
161 
162  <tr id='more_options_link'>
163  <td align="right" class="asearch-line">
164  <a class="nav" onClick="xajax_window_submit('{$window_name}', 'show more', 'more_host_options');">More &gt;&gt;</a>
165  </td>
166  <td align="left" class="asearch-line">
168  </td>
169  </tr>
170 
171  <tr>
172  <td align="left" colspan="2" id="more_host_options"></td>
173  </tr>
174 
175  <tr>
176  <td align="right" class="asearch-line">
177  &nbsp;
178  </td>
179  <td align="right" class="asearch-line">
180  <input class="button" type="reset" name="reset" value="Clear">
181  <input class="button" type="button" name="search" value="Search" accesskey="s" onClick="toggle_window('{$window_name}'); xajax_window_submit('search_results', xajax.getFormValues('host_search_form'));">
182  </td>
183  </tr>
184 
185  </table>
186  </form>
187 
188 
189 
190 
191 
192  <!-- subnet Search Tab -->
193  <form id="subnet_search_form">
194  <input type="hidden" name="search_form_id" value="subnet_search_form">
195  <table id="subnet_search" style="display: none; background-color: {$color['window_content_bg']};" width="100%" cellspacing="0" border="0" cellpadding="0">
196 
197  <tr>
198  <td align="right" class="asearch-line">
199  <u>V</u>lan
200  </td>
201  <td align="left" class="asearch-line">
202  <input id="vlan" name="vlandesc" type="text" class="edit" size="32" accesskey="v" />
203  </td>
204  </tr>
205 
206  <tr>
207  <td align="right" class="asearch-line">
208  Subnet <u>T</u>ype
209  </td>
210  <td align="left" class="asearch-line">
211  <select id="nettype" name="nettype" class="edit" accesskey="u" accesskey="t" >
213  </select>
214  </td>
215  </tr>
216 
217  <tr>
218  <td align="right" class="asearch-line">
219  Subnet <u>N</u>ame
220  </td>
221  <td align="left" class="asearch-line">
222  <input id="subnet" name="subnetname" type="text" class="edit" size="32" accesskey="n" />
223  <div id="suggest_subnet" class="suggest"></div>
224  </td>
225  </tr>
226 
227  <tr>
228  <td align="right" class="asearch-line">
229  <u>I</u>P Address
230  </td>
231  <td align="left" class="asearch-line" nowrap="true">
232  <input id="ip_subnet" name="ip_subnet" class="edit" type="text" size="15" accesskey="i" />
233  <div id="suggest_ip_subnet" class="suggest"></div>
234  thru
235  <input id="ip_subnet_thru" name="ip_subnet_thru" class="edit" type="text" size="15">
236  <div id="suggest_ip_subnet_thru" class="suggest"></div>
237  </td>
238  </tr>
239 
240  <tr>
241  <td align="right" class="asearch-line">
242  &nbsp;
243  </td>
244  <td align="right" class="asearch-line">
245  <input class="button" type="reset" name="reset" value="Clear">
246  <input class="button" type="submit" name="search" value="Search" accesskey="s" onClick="toggle_window('{$window_name}'); xajax_window_submit('search_results', xajax.getFormValues('subnet_search_form'));">
247  </td>
248  </tr>
249 
250  </table>
251  </form>
252 
253 EOL;
254 
255 
256 
257 
259 // Function: ws_more_host_options()
260 //
261 // Description:
262 // Displays additional drop-downs in the advanced search form.
264 function ws_more_host_options($window_name, $form='') {
265  global $conf, $self, $onadb;
266  global $images, $color, $style;
267  $html = '';
268  $js = '';
269 
270  // Build custom attribute list
271  list($status, $rows, $records) = db_get_records($onadb, 'custom_attribute_types', 'id >= 1', '');
272  $custom_attribute_type_list = '<option value="">&nbsp;</option>\n';
273  foreach ($records as $record) {
274  $custom_attribute_type_list .= "<option value=\"{$record['id']}\">{$record['name']}</option>\n";
275  unset($records, $ca);
276  }
277 
278 
279  // Build device model list
280  list($status, $rows, $records) = db_get_records($onadb, 'models', 'id >= 1');
281  $models = array();
282  foreach ($records as $record) {
283  list($status, $rows, $manufacturer) = ona_get_manufacturer_record(array('id' => $record['manufacturer_id']));
284  $models[$record['id']] = "{$manufacturer['name']}, {$record['name']}";
285  }
286  asort($models);
287  $device_model_list = '<option value="">&nbsp;</option>\n';
288  foreach (array_keys($models) as $id) {
289  $models[$id] = htmlentities($models[$id]);
290  $device_model_list .= "<option value=\"{$id}\">{$models[$id]}</option>\n";
291  }
292  unset($models, $model);
293 
294 
295  // Build device type list
296  list($status, $rows, $records) = db_get_records($onadb, 'roles', 'id >= 1', 'name');
297  $device_role_list = '<option value="">&nbsp;</option>\n';
298  $record['name'] = htmlentities($record['name']);
299  foreach ($records as $record) {
300  $device_role_list .= "<option value=\"{$record['id']}\">{$record['name']}</option>\n";
301  }
302 
303 
304  // Build device manufacturer list
305  list($status, $rows, $records) = db_get_records($onadb, 'manufacturers', 'ID >= 1', 'name');
306  $device_manufacturer_list = '<option value="">&nbsp;</option>\n';
307  $record['name'] = htmlentities($record['name']);
308  foreach ($records as $record) {
309  $device_manufacturer_list .= "<option value=\"{$record['id']}\">{$record['name']}</option>\n";
310  }
311 
312 
313  // Build the new HTML
314  $html = <<<EOL
315  <table cellspacing="0" border="0" cellpadding="0">
316  <tr>
317  <td align="right" class="asearch-line">
318  <u>C</u>ustom attribute
319  </td>
320  <td align="left" class="asearch-line">
321  <select id="custom_attribute_type" name="custom_attribute_type" class="edit" accesskey="c">
322  {$custom_attribute_type_list}
323  </select>
324  <u>V</u>alue
325  <input id="ca_value" name="ca_value" type="text" class="edit" size="15" accesskey="v" />
326  </td>
327  </tr>
328 
329  <tr>
330  <td align="right" class="asearch-line">
331  Device mode<u>l</u>
332  </td>
333  <td align="left" class="asearch-line">
334  <select id="model" name="model" class="edit" accesskey="l">
335  {$device_model_list}
336  </select>
337  </td>
338  </tr>
339 
340  <tr>
341  <td align="right" class="asearch-line">
342  Device <u>t</u>ype Role
343  </td>
344  <td align="left" class="asearch-line">
345  <select id="role" name="role" class="edit" accesskey="t">
346  {$device_role_list}
347  </select>
348  </td>
349  </tr>
350 
351  <tr>
352  <td align="right" class="asearch-line">
353  Device man<u>u</u>facturer
354  </td>
355  <td align="left" class="asearch-line">
356  <select id="manufacturer" name="manufacturer" class="edit" accesskey="u">
357  {$device_manufacturer_list}
358  </select>
359  </td>
360  </tr>
361  </table>
362 EOL;
363 
364  $js = "el('more_options_link').style.display = 'none';";
365 
366  // Insert the new html
367  $response = new xajaxResponse();
368  $response->addAssign("more_host_options", "innerHTML", $html);
369  if ($js) { $response->addScript($js); }
370  return($response->getXML());
371 
372 }
373 
374 
375 ?>
ws_more_host_options
ws_more_host_options($window_name, $form='')
Definition: app_advanced_search.inc.php:264
ona_get_manufacturer_record
ona_get_manufacturer_record($array)
Definition: functions_db.inc.php:1210
gt
& gt
Definition: app_advanced_search.inc.php:164
nbsp
</a ></td >< td align="left" class="asearch-line"> & nbsp
Definition: app_advanced_search.inc.php:167
$window
foreach($records as $record) $window['title']
Definition: app_advanced_search.inc.php:20
$record
$record['display_name']
Definition: app_advanced_search.inc.php:12
db_get_records
db_get_records($dbh=0, $table="", $where="", $order="", $rows=-1, $offset=-1)
Definition: functions_db.inc.php:891
$status
$status
Definition: install.php:12
_button
_button
Definition: app_advanced_search.inc.php:48
$images
$images
Definition: config.inc.php:26
$conf
global $conf
Definition: 2-to-3.php:15
xajaxResponse
Definition: xajaxResponse.inc.php:68
$subnet_type_list
$subnet_type_list
Definition: app_advanced_search.inc.php:11
$style
$style['font-family']
Definition: config.inc.php:158
$self
global $self
Definition: 2-to-3.php:15
$onadb
global $onadb
Definition: app_advanced_search.inc.php:6
EOL
EOL
Definition: app_advanced_search.inc.php:68
$color
if($_SERVER['SERVER_PORT']==443) $color['bg']
Definition: config.inc.php:119