Project

General

Profile

Download (14.5 KB) Statistics
| Branch: | Tag: | Revision:
1 d173230c Seth Mos
<?php
2
/*
3 c5d81585 Renato Botelho
 * system_gateways.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6 38809d47 Renato Botelho do Couto
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8 8f2f85c3 Luiz Otavio O Souza
 * Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
9 c5d81585 Renato Botelho
 * Copyright (c) 2010 Seth Mos <seth.mos@dds.nl>
10
 * All rights reserved.
11
 *
12 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
13
 * you may not use this file except in compliance with the License.
14
 * You may obtain a copy of the License at
15 c5d81585 Renato Botelho
 *
16 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
17 c5d81585 Renato Botelho
 *
18 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
19
 * distributed under the License is distributed on an "AS IS" BASIS,
20
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
 * See the License for the specific language governing permissions and
22
 * limitations under the License.
23 6ff05704 Stephen Beaver
 */
24 d173230c Seth Mos
25 6b07c15a Matthew Grooms
##|+PRIV
26
##|*IDENT=page-system-gateways
27 5230f468 jim-p
##|*NAME=System: Gateways
28 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'System: Gateways' page.
29
##|*MATCH=system_gateways.php*
30
##|-PRIV
31
32 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
33 7a927e67 Scott Ullrich
require_once("functions.inc");
34
require_once("filter.inc");
35
require_once("shaper.inc");
36 43a9b03d PiBa-NL
require_once("gwlb.inc");
37
38
$simplefields = array('defaultgw4', 'defaultgw6');
39 d173230c Seth Mos
40 c6c398c6 jim-p
init_config_arr(array('gateways', 'gateway_item'));
41 616e1956 Seth Mos
$a_gateway_item = &$config['gateways']['gateway_item'];
42
43 4611e283 Steve Beaver
$pconfig = $_REQUEST;
44 d173230c Seth Mos
45 e311cb79 PiBa-NL
if ($_POST['order-store']) {
46
	// Include the rules of this (the selected) interface.
47
	// If a rule is not in POST[rule], it has been deleted by the user
48
	$a_gateway_item_new = array();
49
	//print "<pre>";
50
	foreach ($_POST['row'] as $id) {
51
		//print " $id";
52
		$a_gateway_item_new[] = $a_gateway_item[$id];
53
	}
54
	//print_r($a_gateway_item);
55
	//print_r($a_gateway_item_new);
56
	//print "</pre>";
57
	$a_gateway_item = $a_gateway_item_new;
58
	//mark_subsystem_dirty('staticroutes');
59
	write_config("System - Gateways: save default gateway");
60
} else if ($_POST['save']) {
61 43a9b03d PiBa-NL
	unset($input_errors);
62
	$pconfig = $_POST;
63
	foreach($simplefields as $field) {
64
		$config['gateways'][$field] = $pconfig[$field];
65
	}
66
	mark_subsystem_dirty('staticroutes');
67
	write_config("System - Gateways: save default gateway");
68
}
69
70 4611e283 Steve Beaver
if ($_POST['apply']) {
71 d173230c Seth Mos
72 4611e283 Steve Beaver
	$retval = 0;
73 d173230c Seth Mos
74 0b385c4e Viktor G
	/* reconfigure our gateway monitor */
75
	setup_gateways_monitor();
76 4611e283 Steve Beaver
	$retval |= system_routing_configure();
77
	$retval |= system_resolvconf_generate();
78
	$retval |= filter_configure();
79
	/* Dynamic DNS on gw groups may have changed */
80
	send_event("service reload dyndnsall");
81 d173230c Seth Mos
82 4611e283 Steve Beaver
	if ($retval == 0) {
83
		clear_subsystem_dirty('staticroutes');
84 d173230c Seth Mos
	}
85
}
86
87 3cd21b4e PiBa-NL
$a_gateways = return_gateways_array(true, false, true, true);
88 4611e283 Steve Beaver
89 028ff8f8 Phil Davis
function can_delete_disable_gateway_item($id, $disable = false) {
90 e97df865 Renato Botelho
	global $config, $input_errors, $a_gateways;
91 d251a8d4 Renato Botelho
92 e0c7b2fe Phil Davis
	if (!isset($a_gateways[$id])) {
93 e97df865 Renato Botelho
		return false;
94 e0c7b2fe Phil Davis
	}
95 e97df865 Renato Botelho
96
	if (is_array($config['gateways']['gateway_group'])) {
97
		foreach ($config['gateways']['gateway_group'] as $group) {
98
			foreach ($group['item'] as $item) {
99
				$items = explode("|", $item);
100
				if ($items[0] == $a_gateways[$id]['name']) {
101 205178aa Phil Davis
					if (!$disable) {
102 762faef5 Phil Davis
						$input_errors[] = sprintf(gettext('Gateway "%1$s" cannot be deleted because it is in use on Gateway Group "%2$s"'), $a_gateways[$id]['name'], $group['name']);
103 205178aa Phil Davis
					} else {
104 762faef5 Phil Davis
						$input_errors[] = sprintf(gettext('Gateway "%1$s" cannot be disabled because it is in use on Gateway Group "%2$s"'), $a_gateways[$id]['name'], $group['name']);
105 028ff8f8 Phil Davis
					}
106 f78302e8 Ermal
				}
107
			}
108
		}
109 e97df865 Renato Botelho
	}
110
111 475feb89 Christian McDonald
	foreach (config_get_path('staticroutes/route', []) as $route) {
112
		if ($route['gateway'] == $a_gateways[$id]['name']) {
113
			if (!$disable) {
114
				// The user wants to delete this gateway, but there is a static route (enabled or disabled) that refers to the gateway.
115
				$input_errors[] = sprintf(gettext('Gateway "%1$s" cannot be deleted because it is in use on Static Route "%2$s"'), $a_gateways[$id]['name'], $route['network']);
116
			} else if (!isset($route['disabled'])) {
117
				// The user wants to disable this gateway.
118
				// But there is a static route that uses this gateway and is enabled (not disabled).
119
				$input_errors[] = sprintf(gettext('Gateway "%1$s" cannot be disabled because it is in use on Static Route "%2$s"'), $a_gateways[$id]['name'], $route['network']);
120 f78302e8 Ermal
			}
121
		}
122 e97df865 Renato Botelho
	}
123
124 d6bbbf35 Viktor G
	/* prevent removing a gateway if it's still in use by DNS servers
125
	 * see https://redmine.pfsense.org/issues/8390 */
126
	$dnsgw_counter = 1;
127
	init_config_arr(array('system', 'dnsserver'));
128
	foreach ($config['system']['dnsserver'] as $dnsserver) {
129
		if (isset($config["system"]["dns{$dnsgw_counter}gw"]) &&
130
		    ($a_gateways[$id]['name'] == $config["system"]["dns{$dnsgw_counter}gw"])) {
131
				if (!$disable) {
132
					// The user wants to delete this gateway, but there is a static route to the DNS server that refers to the gateway.
133
					$input_errors[] = sprintf(gettext('Gateway "%1$s" cannot be deleted because it is in use by DNS Server "%2$s"'), $a_gateways[$id]['name'], $dnsserver);
134
				} else {
135
					// The user wants to disable this gateway, but there is a static route to the DNS server that refers to the gateway.
136
					$input_errors[] = sprintf(gettext('Gateway "%1$s" cannot be disabled because it is in use by DNS Server "%2$s"'), $a_gateways[$id]['name'], $dnsserver);
137
				}
138
		}
139
		$dnsgw_counter++;
140
	}
141
142 e0c7b2fe Phil Davis
	if (isset($input_errors)) {
143 e97df865 Renato Botelho
		return false;
144 e0c7b2fe Phil Davis
	}
145 e97df865 Renato Botelho
146
	return true;
147
}
148
149
function delete_gateway_item($id) {
150 dde20226 Renato Botelho
	global $config, $a_gateways;
151
152 e0c7b2fe Phil Davis
	if (!isset($a_gateways[$id])) {
153 e97df865 Renato Botelho
		return;
154 e0c7b2fe Phil Davis
	}
155 32a9eb18 Ermal
156 1be1b87b jim-p
	/* If the removed gateway was the default route, remove the default route */
157
	if (!empty($a_gateways[$id]) && is_ipaddr($a_gateways[$id]['gateway']) &&
158
	    !isset($a_gateways[$id]['disabled']) &&
159 43a9b03d PiBa-NL
	    isset($a_gateways[$id]['isdefaultgw'])) {
160 c428cdf4 Renato Botelho do Couto
		$inet = (!is_ipaddrv4($a_gateways[$id]['gateway'])
161
		    ? 'inet6' : 'inet');
162
		route_del('default', $inet);
163 1be1b87b jim-p
	}
164
165 e75f0e7d PiBa-NL
	/* NOTE: Cleanup static routes for the interface route if any */
166 d61309a0 Phil Davis
	if (!empty($a_gateways[$id]) && is_ipaddr($a_gateways[$id]['gateway']) &&
167
	    $gateway['gateway'] != $a_gateways[$id]['gateway'] &&
168
	    isset($a_gateways[$id]["nonlocalgateway"])) {
169 c428cdf4 Renato Botelho do Couto
		route_del($a_gateways[$id]['gateway']);
170 e75f0e7d PiBa-NL
	}
171 e97df865 Renato Botelho
	/* NOTE: Cleanup static routes for the monitor ip if any */
172
	if (!empty($a_gateways[$id]['monitor']) &&
173 d61309a0 Phil Davis
	    $a_gateways[$id]['monitor'] != "dynamic" &&
174
	    is_ipaddr($a_gateways[$id]['monitor']) &&
175
	    $a_gateways[$id]['gateway'] != $a_gateways[$id]['monitor']) {
176 c428cdf4 Renato Botelho do Couto
		route_del($a_gateways[$id]['monitor']);
177 e97df865 Renato Botelho
	}
178
179 e0c7b2fe Phil Davis
	if ($config['interfaces'][$a_gateways[$id]['friendlyiface']]['gateway'] == $a_gateways[$id]['name']) {
180 7e3ea4a8 Christian McDonald
		config_del_path("interfaces/{$a_gateways[$id]['friendlyiface']}/gateway");
181 e0c7b2fe Phil Davis
	}
182 7e3ea4a8 Christian McDonald
	config_del_path("gateways/gateway_item/{$a_gateways[$id]['attribute']}");
183 e97df865 Renato Botelho
}
184
185
unset($input_errors);
186 4611e283 Steve Beaver
if ($_REQUEST['act'] == "del") {
187
	if (can_delete_disable_gateway_item($_REQUEST['id'])) {
188
		$realid = $a_gateways[$_REQUEST['id']]['attribute'];
189
		delete_gateway_item($_REQUEST['id']);
190 e97df865 Renato Botelho
		write_config("Gateways: removed gateway {$realid}");
191
		mark_subsystem_dirty('staticroutes');
192
		header("Location: system_gateways.php");
193
		exit;
194
	}
195
}
196
197 4611e283 Steve Beaver
if (isset($_REQUEST['del_x'])) {
198 e97df865 Renato Botelho
	/* delete selected items */
199 4611e283 Steve Beaver
	if (is_array($_REQUEST['rule']) && count($_REQUEST['rule'])) {
200
		foreach ($_REQUEST['rule'] as $rulei) {
201 028ff8f8 Phil Davis
			if (!can_delete_disable_gateway_item($rulei)) {
202 e97df865 Renato Botelho
				break;
203 e0c7b2fe Phil Davis
			}
204
		}
205 e97df865 Renato Botelho
206
		if (!isset($input_errors)) {
207
			$items_deleted = "";
208 4611e283 Steve Beaver
			foreach ($_REQUEST['rule'] as $rulei) {
209 e97df865 Renato Botelho
				delete_gateway_item($rulei);
210
				$items_deleted .= "{$rulei} ";
211
			}
212
			if (!empty($items_deleted)) {
213 762faef5 Phil Davis
				write_config(sprintf(gettext("Gateways: removed gateways %s", $items_deleted)));
214 e97df865 Renato Botelho
				mark_subsystem_dirty('staticroutes');
215
			}
216 f78302e8 Ermal
			header("Location: system_gateways.php");
217
			exit;
218
		}
219 d173230c Seth Mos
	}
220
221 4611e283 Steve Beaver
} else if ($_REQUEST['act'] == "toggle" && $a_gateways[$_REQUEST['id']]) {
222
	$realid = $a_gateways[$_REQUEST['id']]['attribute'];
223 028ff8f8 Phil Davis
	$disable_gw = !isset($a_gateway_item[$realid]['disabled']);
224
	if ($disable_gw) {
225
		// The user wants to disable the gateway, so check if that is OK.
226 4611e283 Steve Beaver
		$ok_to_toggle = can_delete_disable_gateway_item($_REQUEST['id'], $disable_gw);
227 e0c7b2fe Phil Davis
	} else {
228 028ff8f8 Phil Davis
		// The user wants to enable the gateway. That is always OK.
229
		$ok_to_toggle = true;
230 e0c7b2fe Phil Davis
	}
231 028ff8f8 Phil Davis
	if ($ok_to_toggle) {
232 43a9b03d PiBa-NL
		gateway_set_enabled($a_gateway_item[$realid]['name'], !$disable_gw);
233 e97df865 Renato Botelho
234 028ff8f8 Phil Davis
		if (write_config("Gateways: enable/disable")) {
235
			mark_subsystem_dirty('staticroutes');
236
		}
237 e97df865 Renato Botelho
238 028ff8f8 Phil Davis
		header("Location: system_gateways.php");
239
		exit;
240
	}
241 e97df865 Renato Botelho
}
242 124aee67 Chris Buechler
243 43a9b03d PiBa-NL
foreach($simplefields as $field) {
244
	$pconfig[$field] = $config['gateways'][$field];
245
}
246
247 d036bc07 Stephen Beaver
$pgtitle = array(gettext("System"), gettext("Routing"), gettext("Gateways"));
248 edcd7535 Phil Davis
$pglinks = array("", "@self", "@self");
249 b32dd0a6 jim-p
$shortcut_section = "gateways";
250 02ca24c9 jim-p
251 d173230c Seth Mos
include("head.inc");
252
253 d61309a0 Phil Davis
if ($input_errors) {
254 c3c692a9 Sjon Hortensius
	print_input_errors($input_errors);
255 d61309a0 Phil Davis
}
256 44c42356 Phil Davis
257
if ($_POST['apply']) {
258
	print_apply_result_box($retval);
259 d61309a0 Phil Davis
}
260 f74457df Stephen Beaver
261 d61309a0 Phil Davis
if (is_subsystem_dirty('staticroutes')) {
262 7fdca5ff NOYB
	print_apply_box(gettext("The gateway configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
263 d61309a0 Phil Davis
}
264 c3c692a9 Sjon Hortensius
265
$tab_array = array();
266
$tab_array[0] = array(gettext("Gateways"), true, "system_gateways.php");
267 80b4d0c5 heper
$tab_array[1] = array(gettext("Static Routes"), false, "system_routes.php");
268
$tab_array[2] = array(gettext("Gateway Groups"), false, "system_gateway_groups.php");
269 c3c692a9 Sjon Hortensius
display_top_tabs($tab_array);
270 d173230c Seth Mos
271 d251a8d4 Renato Botelho
?>
272 e311cb79 PiBa-NL
<form method="post">
273 060ed238 Stephen Beaver
<div class="panel panel-default">
274
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Gateways')?></h2></div>
275
	<div class="panel-body">
276
		<div class="table-responsive">
277 e311cb79 PiBa-NL
			<table id="gateways" class="table table-striped table-hover table-condensed table-rowdblclickedit">
278 060ed238 Stephen Beaver
				<thead>
279
					<tr>
280 e311cb79 PiBa-NL
						<th></th>
281 060ed238 Stephen Beaver
						<th></th>
282
						<th><?=gettext("Name")?></th>
283 43a9b03d PiBa-NL
						<th><?=gettext("Default")?></th>
284 060ed238 Stephen Beaver
						<th><?=gettext("Interface")?></th>
285
						<th><?=gettext("Gateway")?></th>
286
						<th><?=gettext("Monitor IP")?></th>
287
						<th><?=gettext("Description")?></th>
288
						<th><?=gettext("Actions")?></th>
289
					</tr>
290
				</thead>
291
				<tbody>
292 e97df865 Renato Botelho
<?php
293 c3c692a9 Sjon Hortensius
foreach ($a_gateways as $i => $gateway):
294 d61309a0 Phil Davis
	if (isset($gateway['inactive'])) {
295 8326101f Steve Beaver
		$title = gettext("Gateway inactive, interface is missing");
296 1b7379f9 Jared Dillard
		$icon = 'fa-times-circle-o';
297 d61309a0 Phil Davis
	} elseif (isset($gateway['disabled'])) {
298 1b7379f9 Jared Dillard
		$icon = 'fa-ban';
299 8326101f Steve Beaver
		$title = gettext("Gateway disabled");
300 d61309a0 Phil Davis
	} else {
301 1b7379f9 Jared Dillard
		$icon = 'fa-check-circle-o';
302 8326101f Steve Beaver
		$title = gettext("Gateway enabled");
303 d61309a0 Phil Davis
	}
304 c3c692a9 Sjon Hortensius
305 8326101f Steve Beaver
	$gtitle = "";
306
	if (isset($gateway['isdefaultgw'])) {
307
		$gtitle = gettext("Default gateway");
308 d61309a0 Phil Davis
	}
309 8326101f Steve Beaver
310 e311cb79 PiBa-NL
	$id = $gateway['attribute'];
311 e97df865 Renato Botelho
?>
312 5a764497 Steve Beaver
					<tr<?=($icon != 'fa-check-circle-o')? ' class="disabled"' : ''?> onClick="fr_toggle(<?=$id;?>)" id="fr<?=$id;?>">
313
						<td style="white-space: nowrap;">
314
							<?php 
315
							if (is_numeric($id)) :?>
316
								<input type='checkbox' id='frc<?=$id?>' onClick='fr_toggle(<?=$id?>)' name='row[]' value='<?=$id?>'/>
317
								<a class='fa fa-anchor' id='Xmove_<?=$id?>' title='"<?=gettext("Move checked entries to here")?>"'></a>
318
							<?php endif; ?>
319
						</td>
320
						<td title="<?=$title?>"><i class="fa <?=$icon?>"></i></td>
321
						<td title="<?=$gtitle?>">
322 060ed238 Stephen Beaver
						<?=htmlspecialchars($gateway['name'])?>
323 e97df865 Renato Botelho
<?php
324 5a764497 Steve Beaver
							if (isset($gateway['isdefaultgw'])) {
325
								echo ' <i class="fa fa-globe"></i>';
326
							}
327 e97df865 Renato Botelho
?>
328 060ed238 Stephen Beaver
						</td>
329 43a9b03d PiBa-NL
						<td>
330 2cff9cf0 Steve Beaver
							<?=htmlspecialchars($gateway['tiername'])?>
331 43a9b03d PiBa-NL
						</td>
332 060ed238 Stephen Beaver
						<td>
333 a2ec7b0a Steve Beaver
							<?=htmlspecialchars($gateway['friendlyifdescr'])?>
334 060ed238 Stephen Beaver
						</td>
335
						<td>
336
							<?=htmlspecialchars($gateway['gateway'])?>
337
						</td>
338
						<td>
339
							<?=htmlspecialchars($gateway['monitor'])?>
340
						</td>
341
						<td>
342
							<?=htmlspecialchars($gateway['descr'])?>
343
						</td>
344 e311cb79 PiBa-NL
						<td style="white-space: nowrap;">
345 4611e283 Steve Beaver
							<a href="system_gateways_edit.php?id=<?=$i?>" class="fa fa-pencil" title="<?=gettext('Edit gateway');?>"></a>
346
							<a href="system_gateways_edit.php?dup=<?=$i?>" class="fa fa-clone" title="<?=gettext('Copy gateway')?>"></a>
347 f74457df Stephen Beaver
348 fa172bc5 NewEraCracker
<?php if (is_numeric($gateway['attribute'])): ?>
349 1629e8ea heper
	<?php if (isset($gateway['disabled'])) {
350 f74457df Stephen Beaver
	?>
351 a04f6658 Steve Beaver
							<a href="?act=toggle&amp;id=<?=$i?>" class="fa fa-check-square-o" title="<?=gettext('Enable gateway')?>" usepost></a>
352 1629e8ea heper
	<?php } else {
353
	?>
354 a04f6658 Steve Beaver
							<a href="?act=toggle&amp;id=<?=$i?>" class="fa fa-ban" title="<?=gettext('Disable gateway')?>" usepost></a>
355 1629e8ea heper
	<?php }
356 f74457df Stephen Beaver
	?>
357 a04f6658 Steve Beaver
							<a href="system_gateways.php?act=del&amp;id=<?=$i?>" class="fa fa-trash" title="<?=gettext('Delete gateway')?>" usepost></a>
358 f74457df Stephen Beaver
359 fa172bc5 NewEraCracker
<?php endif; ?>
360 060ed238 Stephen Beaver
						</td>
361
					</tr>
362 fa172bc5 NewEraCracker
<?php endforeach; ?>
363 060ed238 Stephen Beaver
				</tbody>
364
			</table>
365
		</div>
366
	</div>
367
</div>
368 c3c692a9 Sjon Hortensius
369 c10cb196 Stephen Beaver
<nav class="action-buttons">
370 e311cb79 PiBa-NL
	<button type="submit" id="order-store" name="order-store" class="btn btn-sm btn-primary" value="store changes" disabled title="<?=gettext('Save rule order')?>">
371
		<i class="fa fa-save icon-embed-btn"></i>
372
		<?=gettext("Save")?>
373
	</button>
374 4611e283 Steve Beaver
	<a href="system_gateways_edit.php" role="button" class="btn btn-success">
375 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
376 f74457df Stephen Beaver
		<?=gettext("Add");?>
377 c3c692a9 Sjon Hortensius
	</a>
378
</nav>
379 e311cb79 PiBa-NL
</form>
380 e97df865 Renato Botelho
<?php
381 c3c692a9 Sjon Hortensius
382 43a9b03d PiBa-NL
$form = new Form;
383
$section = new Form_Section('Default gateway');
384
385 1cf01478 Steve Beaver
$dflts = available_default_gateways();
386 43a9b03d PiBa-NL
387
$section->addInput(new Form_Select(
388
	'defaultgw4',
389
	'Default gateway IPv4',
390
	$pconfig['defaultgw4'],
391 1cf01478 Steve Beaver
	$dflts['v4']
392 15f716d8 Danilo Zrenjanin
))->setHelp('Select a gateway or failover gateway group to use as the default gateway.');
393 43a9b03d PiBa-NL
394
$section->addInput(new Form_Select(
395
	'defaultgw6',
396
	'Default gateway IPv6',
397
	$pconfig['defaultgw6'],
398 1cf01478 Steve Beaver
	$dflts['v6']
399 15f716d8 Danilo Zrenjanin
))->setHelp('Select a gateway or failover gateway group to use as the default gateway.');
400 43a9b03d PiBa-NL
401
$form->add($section);
402
print $form;
403
404 e311cb79 PiBa-NL
?>
405 3cd21b4e PiBa-NL
<div class="infoblock">
406
<?php
407
print_info_box(
408 8326101f Steve Beaver
	sprintf(gettext('%1$s The current default route as present in the current routing table of the operating system'), '<strong><i class="fa fa-globe"></i></strong>') .
409
	sprintf(gettext('%1$s Gateway is inactive, interface is missing'), '<br /><strong><i class="fa fa-times-circle-o"></i></strong>') .
410
	sprintf(gettext('%1$s Gateway disabled'), '<br /><strong><i class="fa fa-ban"></i></strong>') .
411
	sprintf(gettext('%1$s Gateway enabled'), '<br /><strong><i class="fa fa-check-circle-o"></i></strong>')
412 3cd21b4e PiBa-NL
	);
413
?>
414
</div>
415 e311cb79 PiBa-NL
<script type="text/javascript">
416
//<![CDATA[
417
events.push(function() {
418
	$('#order-store').click(function () {
419
		// Check all of the rule checkboxes so that their values are posted
420
	   $('[id^=frc]').prop('checked', true);
421
	});
422
423
	$('[id^=Xmove_]').click(function (event) {
424
		// anchor click to move gateways around..
425
		moveRowUpAboveAnchor(event.target.id.slice(6),"gateways");
426
		return false;
427
	});
428
	$('[id^=Xmove_]').css('cursor', 'pointer');
429
});
430
	function moveRowUpAboveAnchor(rowId, tableId) {
431
		var table = $('#'+tableId);
432
		var viewcheckboxes = $('[id^=frc]input:checked', table);
433
		var rowview = $("#fr" + rowId, table);
434
		var moveabove = rowview;
435
		//var parent = moveabove[0].parentNode;
436
		
437
		viewcheckboxes.each(function( index ) {
438
			var moveid = this.value;
439
			console.log( index + ": " + this.id );
440
441
			var prevrowview = $("#fr" + moveid, table);
442
			prevrowview.insertBefore(moveabove);
443
			$('#order-store').removeAttr('disabled');
444
		});
445
	}
446
//]]>
447
</script>
448
449
<?php include("foot.inc");