1<?php
2/*
3 * VLAN Import
4 ************************************************/
5
6# include required scripts
7require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
8
9# initialize user object
10$Database 	= new Database_PDO;
11$User = new User ($Database);
12
13# verify that user is logged in, to guard against direct access of page and possible exploits
14$User->check_user_session();
15
16# load data from uploaded file
17include 'import-load-data.php';
18# check data and mark the entries to import/update
19include 'import-vlan-check.php';
20
21?>
22
23<!-- header -->
24<div class="pHeader"><?php print _("VLAN import"); ?></div>
25
26<!-- content -->
27<div class="pContent">
28
29<?php
30
31$msg = "";
32$rows = "";
33
34# import VLANs
35foreach ($data as &$cdata) {
36	if (($cdata['action'] == "add") || ($cdata['action'] == "edit")) {
37		# set update array
38		$values = array("vlanId"=>$cdata['vlanId'],
39						"number"=>$cdata['number'],
40						"name"=>$cdata['name'],
41						"description"=>$cdata['description'],
42						"domainId"=>$cdata['domainId']
43						);
44		# add custom fields
45		if(sizeof($custom_fields) > 0) {
46			foreach($custom_fields as $myField) {
47				if(isset($cdata[$myField['name']])) { $values[$myField['name']] = $cdata[$myField['name']]; }
48			}
49		}
50
51		# update
52		$cdata['result'] = $Admin->object_modify("vlans", $cdata['action'], "vlanId", $values);
53
54		if ($cdata['result']) {
55			$trc = $colors[$cdata['action']];
56			$msg = "VLAN ".$cdata['action']." successful.";
57		} else {
58			$trc = "danger";
59			$msg = "VLAN ".$cdata['action']." failed.";
60		}
61		$rows.="<tr class='".$trc."'><td><i class='fa ".$icons[$cdata['action']]."' rel='tooltip' data-placement='bottom' title='"._($msg)."'></i></td>
62			<td>".$cdata['name']."</td>
63			<td>".$cdata['number']."</td>
64			<td>".$cdata['description']."</td>
65			<td>".$cdata['domain']."</td>
66			".$cfieldtds."
67			<td>"._($msg)."</td></tr>";
68	}
69}
70
71print "<table class='table table-condensed table-hover' id='resultstable'><tbody>";
72print "<tr class='active'>".$hrow."<th>Result</th></tr>";
73print $rows;
74print "</tbody></table><br>";
75?>
76
77</div>
78
79<!-- footer -->
80<div class="pFooter">
81	<button class="btn btn-sm btn-default hidePopups"><?php print _('Close'); ?></button>
82</div>
83