1<h4><?php print _("VRF"); ?></h4>
2<hr>
3<span class="text-muted"><?php print _("All VRF belonging to customer"); ?>.</span>
4
5<script type="text/javascript">
6/* fix for ajax-loading tooltips */
7$('body').tooltip({ selector: '[rel=tooltip]' });
8</script>
9
10
11<?php
12
13# only if set
14if (isset($objects["vrf"])) {
15
16	# get all VLANs and subnet descriptions
17	$vrfs = $objects['vrf'];
18
19	# get custom VLAN fields
20	$custom_fields = (array) $Tools->fetch_custom_fields('vrf');
21
22	# set hidden fields
23	$hidden_fields = json_decode($User->settings->hiddenCustomFields, true);
24	$hidden_fields = is_array(@$hidden_fields['vrf']) ? $hidden_fields['vrf'] : array();
25
26	# size of custom fields
27	$csize = sizeof($custom_fields) - sizeof($hidden_fields);
28
29	# set disabled for non-admins
30	$disabled = $User->is_admin(false)==true ? "" : "hidden";
31
32
33	# table
34	print "<table class='table sorted vrf table-condensed table-top' data-cookie-id-table='customer_vrfs'>";
35
36	# headers
37	print "<thead>";
38	print '<tr">' . "\n";
39	print ' <th data-field="vlname" data-sortable="true">'._('Name').'</th>' . "\n";
40	print ' <th data-field="name" data-sortable="true">'._('Description').'</th>' . "\n";
41	if(sizeof(@$custom_fields) > 0) {
42		foreach($custom_fields as $field) {
43			if(!in_array($field['name'], $hidden_fields)) {
44				print "	<th class='hidden-xs hidden-sm hidden-md'>".$Tools->print_custom_field_name ($field['name'])."</th>";
45			}
46		}
47	}
48    print "<th></th>";
49	print "</tr>";
50	print "</thead>";
51
52	// body
53	print "<tbody>";
54	$m = 0;
55	foreach ($vrfs as $vrf) {
56
57		// start - VLAN details
58		print "<tr class='$class change'>";
59		print "	<td><a class='btn btn-xs btn-default' href='".create_link($_GET['page'], "vrf", $vrf->vrfId)."'><i class='fa fa-cloud prefix'></i> ".$vrf->name."</a></td>";
60		print "	<td>".$vrf->description."</td>";
61        // custom fields - no subnets
62        if(sizeof(@$custom_fields) > 0) {
63	   		foreach($custom_fields as $field) {
64		   		# hidden
65		   		if(!in_array($field['name'], $hidden_fields)) {
66					print "<td class='hidden-xs hidden-sm hidden-md'>";
67					$Tools->print_custom_field ($field['type'], $vrf->{$field['name']});
68					print "</td>";
69				}
70	    	}
71	    }
72
73		// actions
74        print "<td class='actions'>";
75        $links = [];
76        $links[] = ["type"=>"header", "text"=>"Show"];
77        $links[] = ["type"=>"link", "text"=>"Show VRF", "href"=>create_link($_GET['page'], "vrf", $vrf->vrfId), "icon"=>"eye", "visible"=>"dropdown"];
78        $links[] = ["type"=>"divider"];
79        if($User->get_module_permissions ("vrf")>1) {
80            $links[] = ["type"=>"header", "text"=>"Manage"];
81            $links[] = ["type"=>"link", "text"=>"Edit VRF", "href"=>"", "class"=>"open_popup", "dataparams"=>" data-script='app/admin/vrf/edit.php' data-class='700' data-action='edit' data-vrfid='$vrf->vrfId'", "icon"=>"pencil"];
82        }
83        if($User->get_module_permissions ("vrf")>2) {
84            $links[] = ["type"=>"link", "text"=>"Delete VRF", "href"=>"", "class"=>"open_popup", "dataparams"=>" data-script='app/admin/vrf/edit.php' data-class='700' data-action='delete' data-vrfid='$vrf->vrfId'", "icon"=>"times"];
85        }
86		if($User->get_module_permissions ("customers")>1) {
87	        $links[] = ["type"=>"divider"];
88            $links[] = ["type"=>"header", "text"=>"Unlink"];
89            $links[] = ["type"=>"link", "text"=>"Unlink object", "href"=>"", "class"=>"open_popup", "dataparams"=>" data-script='app/admin/customers/unlink.php' data-class='700' data-object='vrf' data-id='$vrf->vrfId'", "icon"=>"times"];
90		}
91        // print links
92        print $User->print_actions($User->user->compress_actions, $links);
93        print "</td>";
94
95        print "</tr>";
96
97		# next index
98		$m++;
99	}
100	print "</tbody>";
101
102	print '</table>';
103}
104else {
105	$Result->show("info", _("No objects"));
106}