1<?php
2/**
3 * Display VRF details
4 ***********************/
5
6# verify that user is logged in
7$User->check_user_session();
8# perm check
9$User->check_module_permissions ("vrf", 1, true, false);
10
11# not existing
12if(!$vrf) { $Result->show("danger", _('Invalid VRF id'), true); }
13
14# get custom VLAN fields
15$cfields = $Tools->fetch_custom_fields ('vrf');
16?>
17
18<!-- for adding IP address! -->
19<div id="subnetId" style="display:none"><?php print $subnetId; ?></div>
20
21<!-- subnet details upper table -->
22<h4><?php print _('VRF details'); ?></h4>
23<hr>
24
25
26<div class="btn-group" style='margin-bottom:10px;'>
27    <a href='<?php print create_link($_GET['page'], "vrf"); ?>' class='btn btn-sm btn-default'><i class='fa fa-angle-left'></i> <?php print _("All VRFs"); ?></a>
28</div>
29
30<table class="ipaddress_subnet table-condensed table-full">
31	<tr>
32		<th><?php print _('RD'); ?></th>
33		<td><?php print $vrf->rd; ?></td>
34	</tr>
35	<tr>
36		<th><?php print _('Name'); ?></th>
37		<td>
38			<?php print $vrf->name; ?>
39		</td>
40	</tr>
41	<tr>
42		<th><?php print _('Description'); ?></th>
43		<td><?php print $vrf->description; ?></td>
44	</tr>
45
46	<tr>
47        <td><hr></td>
48        <td></td>
49	</tr>
50	<tr>
51		<th><?php print _('Sections'); ?></th>
52		<td>
53        <div class="text-muted">
54        <?php
55        	// format sections
56        	if(strlen($vrf->sections)==0) {
57        		$sections = "All sections";
58        	}
59        	else {
60        		//explode
61        		$sections_tmp = explode(";", $vrf->sections);
62        		foreach($sections_tmp as $t) {
63        			//fetch section
64        			$tmp_section = $Sections->fetch_section(null, $t);
65        			$sec[] = $tmp_section->name;
66        		}
67        		//implode
68        		$sections = implode("<br>", $sec);
69        	}
70        	print $sections;
71        ?>
72        </div>
73		</td>
74	</tr>
75
76	<tr>
77		<th><?php print _('Description'); ?></th>
78		<td><?php print $vrf->description; ?></td>
79	</tr>
80
81	<?php
82	// customers
83	if($User->settings->enableCustomers=="1" && $User->get_module_permissions ("customers")>0) {
84		 $customer = $Tools->fetch_object ("customers", "id", $vrf->customer_id);
85
86		 print "<tr>";
87		 print "	<th>"._("Customer")."</th>";
88		 print "	<td>";
89		 if ($customer===false) {
90		 		print "<span class='text-muted'>/</span>";
91		 }
92		 else {
93			print "<span>".$customer->title." <a target='_blank' href='".create_link("tools","customers",$customer->title)."'><i class='fa fa-external-link'></i></a></span>";
94		 }
95		 print "	</td>";
96		 print "</tr>";
97	}
98	?>
99
100	<?php
101
102	# print custom subnet fields if any
103	if(sizeof($cfields) > 0) {
104		// divider
105		print "<tr><td><hr></td><td></td></tr>";
106		// fields
107		foreach($cfields as $key=>$field) {
108			$vrf->{$key} = str_replace("\n", "<br>",$vrf->{$key});
109			// create links
110			$vrf->{$key} = $Result->create_links($vrf->{$key});
111			print "<tr>";
112			print "	<th>$key</th>";
113			print "	<td style='vertical-align:top;align:left;'>".$vrf->{$key}."</td>";
114			print "</tr>";
115		}
116		// divider
117		print "<tr><td><hr></td><td></td></tr>";
118	}
119
120	# permissions
121	if($User->get_module_permissions ("vrf")>1) {
122		# action button groups
123		print "<tr>";
124		print "	<th style='vertical-align:bottom;align:left;'>"._('Actions')."</th>";
125		print "	<td style='vertical-align:bottom;align:left;'>";
126
127		// actions
128        $links = [];
129        if($User->get_module_permissions ("vrf")>1) {
130            $links[] = ["type"=>"header", "text"=>"Manage"];
131            $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"];
132        }
133        if($User->get_module_permissions ("vrf")>2) {
134            $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"];
135        }
136        // print links
137        print $User->print_actions($User->user->compress_actions, $links, true, true);
138		print "	</td>";
139		print "</tr>";
140	}
141	?>
142
143</table>	<!-- end subnet table -->
144<br>