@@ -72,24 +72,24 @@ |
||
72 | 72 | <tr> |
73 | 73 | <td><?php print _('Type'); ?></td> |
74 | 74 | <?php |
75 | - // define supported types |
|
76 | - $mTypes = array("varchar"=>"varchar", "integer"=>"int", "boolean"=>"bool", "text"=>"text", "date"=>"date", "datetime"=>"datetime", "set"=>"set", "enum"=>"enum"); |
|
77 | - //reformat old type |
|
78 | - $oldMType = strstr(@$fieldval['Type'], "(", true); |
|
79 | - $oldMSize = str_replace(array("(",")"), "",strstr(@$fieldval['Type'], "(", false)); |
|
80 | - |
|
81 | - //exceptions |
|
82 | - if(@$fieldval['Type']=="text" || @$fieldval['Type']=="date" || @$fieldval['Type']=="datetime" || @$fieldval['Type']=="set" || @$fieldval['Type']=="enum") { $oldMType = @$fieldval['Type']; } |
|
83 | - ?> |
|
75 | + // define supported types |
|
76 | + $mTypes = array("varchar"=>"varchar", "integer"=>"int", "boolean"=>"bool", "text"=>"text", "date"=>"date", "datetime"=>"datetime", "set"=>"set", "enum"=>"enum"); |
|
77 | + //reformat old type |
|
78 | + $oldMType = strstr(@$fieldval['Type'], "(", true); |
|
79 | + $oldMSize = str_replace(array("(",")"), "",strstr(@$fieldval['Type'], "(", false)); |
|
80 | + |
|
81 | + //exceptions |
|
82 | + if(@$fieldval['Type']=="text" || @$fieldval['Type']=="date" || @$fieldval['Type']=="datetime" || @$fieldval['Type']=="set" || @$fieldval['Type']=="enum") { $oldMType = @$fieldval['Type']; } |
|
83 | + ?> |
|
84 | 84 | <td> |
85 | 85 | <select name="fieldType" class="input-sm input-w-auto form-control"> |
86 | 86 | <?php |
87 | - foreach($mTypes as $name=>$type) { |
|
88 | - if($type==$oldMType) { print "<option value='$type' selected='selected'>$name</option>"; } |
|
89 | - elseif($type=="bool" && $oldMType=="tinyint") { print "<option value='$type' selected='selected'>$name</option>"; } |
|
90 | - else { print "<option value='$type'>$name</option>"; } |
|
91 | - } |
|
92 | - ?> |
|
87 | + foreach($mTypes as $name=>$type) { |
|
88 | + if($type==$oldMType) { print "<option value='$type' selected='selected'>$name</option>"; } |
|
89 | + elseif($type=="bool" && $oldMType=="tinyint") { print "<option value='$type' selected='selected'>$name</option>"; } |
|
90 | + else { print "<option value='$type'>$name</option>"; } |
|
91 | + } |
|
92 | + ?> |
|
93 | 93 | </select> |
94 | 94 | </td> |
95 | 95 | </tr> |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | # fetch all Device types and reindex |
17 | 17 | $device_types = $Admin->fetch_all_objects("deviceTypes", "tid"); |
18 | 18 | if ($device_types !== false) { |
19 | - foreach ($device_types as $dt) { |
|
20 | - $device_types_i[$dt->tid] = $dt; |
|
21 | - } |
|
19 | + foreach ($device_types as $dt) { |
|
20 | + $device_types_i[$dt->tid] = $dt; |
|
21 | + } |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | # fetch custom fields |
@@ -39,65 +39,65 @@ discard block |
||
39 | 39 | <?php |
40 | 40 | /* first check if they exist! */ |
41 | 41 | if($devices===false) { |
42 | - $Result->show("warn alert-absolute", _('No devices configured').'!', false); |
|
42 | + $Result->show("warn alert-absolute", _('No devices configured').'!', false); |
|
43 | 43 | } |
44 | 44 | /* Print them out */ |
45 | 45 | else { |
46 | 46 | |
47 | - print '<table id="switchManagement" class="table table-striped sorted table-td-top">'; |
|
47 | + print '<table id="switchManagement" class="table table-striped sorted table-td-top">'; |
|
48 | 48 | |
49 | - # headers |
|
50 | - print "<thead>"; |
|
51 | - print '<tr>'; |
|
52 | - print ' <th>'._('Name').'</th>'; |
|
53 | - print ' <th>'._('IP address').'</th>'; |
|
54 | - print ' <th>'._('Type').'</th>'; |
|
55 | - print ' <th>'._('Description').'</th>'; |
|
49 | + # headers |
|
50 | + print "<thead>"; |
|
51 | + print '<tr>'; |
|
52 | + print ' <th>'._('Name').'</th>'; |
|
53 | + print ' <th>'._('IP address').'</th>'; |
|
54 | + print ' <th>'._('Type').'</th>'; |
|
55 | + print ' <th>'._('Description').'</th>'; |
|
56 | 56 | if($User->settings->enableSNMP=="1") |
57 | - print ' <th>'._('SNMP').'</th>'; |
|
57 | + print ' <th>'._('SNMP').'</th>'; |
|
58 | 58 | if($User->settings->enableRACK=="1") |
59 | - print ' <th>'._('Rack').'</th>'; |
|
60 | - print ' <th><i class="icon-gray icon-info-sign" rel="tooltip" title="'._('Shows in which sections device will be visible for selection').'"></i> '._('Sections').'</th>'; |
|
61 | - if(sizeof($custom) > 0) { |
|
62 | - foreach($custom as $field) { |
|
63 | - if(!in_array($field['name'], $hidden_custom_fields)) { |
|
64 | - print "<th class='hidden-xs hidden-sm hidden-md'>$field[name]</th>"; |
|
65 | - } |
|
66 | - } |
|
67 | - } |
|
68 | - print ' <th class="actions"></th>'; |
|
69 | - print '</tr>'; |
|
59 | + print ' <th>'._('Rack').'</th>'; |
|
60 | + print ' <th><i class="icon-gray icon-info-sign" rel="tooltip" title="'._('Shows in which sections device will be visible for selection').'"></i> '._('Sections').'</th>'; |
|
61 | + if(sizeof($custom) > 0) { |
|
62 | + foreach($custom as $field) { |
|
63 | + if(!in_array($field['name'], $hidden_custom_fields)) { |
|
64 | + print "<th class='hidden-xs hidden-sm hidden-md'>$field[name]</th>"; |
|
65 | + } |
|
66 | + } |
|
67 | + } |
|
68 | + print ' <th class="actions"></th>'; |
|
69 | + print '</tr>'; |
|
70 | 70 | print "</thead>"; |
71 | 71 | |
72 | 72 | print "<tbody>"; |
73 | - # loop through devices |
|
74 | - foreach ($devices as $device) { |
|
75 | - //cast |
|
76 | - $device = (array) $device; |
|
77 | - |
|
78 | - //print details |
|
79 | - print '<tr>'. "\n"; |
|
80 | - |
|
81 | - print ' <td><a href="'.create_link("tools","devices","hosts",$device['id']).'">'. $device['hostname'] .'</a></td>'. "\n"; |
|
82 | - print ' <td>'. $device['ip_addr'] .'</td>'. "\n"; |
|
83 | - print ' <td>'. @$device_types_i[$device['type']]->tname .'</td>'. "\n"; |
|
84 | - print ' <td class="description">'. $device['description'] .'</td>'. "\n"; |
|
85 | - |
|
86 | - // SNMP |
|
87 | - if($User->settings->enableSNMP=="1") { |
|
88 | - print "<td>"; |
|
89 | - // not set |
|
90 | - if ($device['snmp_version']==0 || strlen($device['snmp_version'])==0) { |
|
91 | - print "<span class='text-muted'>"._("Disabled")."</span>"; |
|
92 | - } |
|
93 | - else { |
|
73 | + # loop through devices |
|
74 | + foreach ($devices as $device) { |
|
75 | + //cast |
|
76 | + $device = (array) $device; |
|
77 | + |
|
78 | + //print details |
|
79 | + print '<tr>'. "\n"; |
|
80 | + |
|
81 | + print ' <td><a href="'.create_link("tools","devices","hosts",$device['id']).'">'. $device['hostname'] .'</a></td>'. "\n"; |
|
82 | + print ' <td>'. $device['ip_addr'] .'</td>'. "\n"; |
|
83 | + print ' <td>'. @$device_types_i[$device['type']]->tname .'</td>'. "\n"; |
|
84 | + print ' <td class="description">'. $device['description'] .'</td>'. "\n"; |
|
85 | + |
|
86 | + // SNMP |
|
87 | + if($User->settings->enableSNMP=="1") { |
|
88 | + print "<td>"; |
|
89 | + // not set |
|
90 | + if ($device['snmp_version']==0 || strlen($device['snmp_version'])==0) { |
|
91 | + print "<span class='text-muted'>"._("Disabled")."</span>"; |
|
92 | + } |
|
93 | + else { |
|
94 | 94 | print _("Version").": $device[snmp_version]<br>"; |
95 | 95 | print _("Community").": $device[snmp_community]<br>"; |
96 | - } |
|
97 | - print "</td>"; |
|
98 | - } |
|
96 | + } |
|
97 | + print "</td>"; |
|
98 | + } |
|
99 | 99 | |
100 | - // rack |
|
100 | + // rack |
|
101 | 101 | if($User->settings->enableRACK=="1") { |
102 | 102 | print "<td>"; |
103 | 103 | # rack |
@@ -109,62 +109,62 @@ discard block |
||
109 | 109 | print "</td>"; |
110 | 110 | } |
111 | 111 | |
112 | - //sections |
|
113 | - print ' <td class="sections">'; |
|
114 | - $temp = explode(";",$device['sections']); |
|
115 | - if( (sizeof($temp) > 0) && (!empty($temp[0])) ) { |
|
116 | - foreach($temp as $line) { |
|
117 | - $section = $Sections->fetch_section(null, $line); |
|
118 | - if(!empty($section)) { |
|
119 | - print '<div class="switchSections text-muted">'. $section->name .'</div>'. "\n"; |
|
120 | - } |
|
121 | - } |
|
122 | - } |
|
123 | - |
|
124 | - print ' </td>'. "\n"; |
|
125 | - |
|
126 | - //custom |
|
127 | - if(sizeof($custom) > 0) { |
|
128 | - foreach($custom as $field) { |
|
129 | - if(!in_array($field['name'], $hidden_custom_fields)) { |
|
130 | - print "<td class='hidden-xs hidden-sm hidden-md'>"; |
|
131 | - |
|
132 | - // create links |
|
133 | - $device[$field['name']] = $Result->create_links ($device[$field['name']], $field['type']); |
|
134 | - |
|
135 | - //booleans |
|
136 | - if($field['type']=="tinyint(1)") { |
|
137 | - if($device[$field['name']] == "0") { print _("No"); } |
|
138 | - elseif($device[$field['name']] == "1") { print _("Yes"); } |
|
139 | - } |
|
140 | - //text |
|
141 | - elseif($field['type']=="text") { |
|
142 | - if(strlen($device[$field['name']])>0) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $device[$field['name']])."'>"; } |
|
143 | - else { print ""; } |
|
144 | - } |
|
145 | - else { |
|
146 | - print $device[$field['name']]; |
|
147 | - |
|
148 | - } |
|
149 | - print "</td>"; |
|
150 | - } |
|
151 | - } |
|
152 | - } |
|
153 | - |
|
154 | - print ' <td class="actions">'. "\n"; |
|
155 | - print " <div class='btn-group'>"; |
|
156 | - print " <button class='btn btn-xs btn-default editSwitch' data-action='edit' data-switchid='$device[id]'><i class='fa fa-pencil'></i></button>"; |
|
157 | - if($User->settings->enableSNMP=="1") |
|
158 | - print " <button class='btn btn-xs btn-default editSwitchSNMP' data-action='edit' data-switchid='$device[id]'><i class='fa fa-cogs'></i></button>"; |
|
159 | - print " <button class='btn btn-xs btn-default editSwitch' data-action='delete' data-switchid='$device[id]'><i class='fa fa-times'></i></button>"; |
|
160 | - print " </div>"; |
|
161 | - print ' </td>'. "\n"; |
|
162 | - |
|
163 | - print '</tr>'. "\n"; |
|
164 | - |
|
165 | - } |
|
166 | - print "</tbody>"; |
|
167 | - print '</table>'; |
|
112 | + //sections |
|
113 | + print ' <td class="sections">'; |
|
114 | + $temp = explode(";",$device['sections']); |
|
115 | + if( (sizeof($temp) > 0) && (!empty($temp[0])) ) { |
|
116 | + foreach($temp as $line) { |
|
117 | + $section = $Sections->fetch_section(null, $line); |
|
118 | + if(!empty($section)) { |
|
119 | + print '<div class="switchSections text-muted">'. $section->name .'</div>'. "\n"; |
|
120 | + } |
|
121 | + } |
|
122 | + } |
|
123 | + |
|
124 | + print ' </td>'. "\n"; |
|
125 | + |
|
126 | + //custom |
|
127 | + if(sizeof($custom) > 0) { |
|
128 | + foreach($custom as $field) { |
|
129 | + if(!in_array($field['name'], $hidden_custom_fields)) { |
|
130 | + print "<td class='hidden-xs hidden-sm hidden-md'>"; |
|
131 | + |
|
132 | + // create links |
|
133 | + $device[$field['name']] = $Result->create_links ($device[$field['name']], $field['type']); |
|
134 | + |
|
135 | + //booleans |
|
136 | + if($field['type']=="tinyint(1)") { |
|
137 | + if($device[$field['name']] == "0") { print _("No"); } |
|
138 | + elseif($device[$field['name']] == "1") { print _("Yes"); } |
|
139 | + } |
|
140 | + //text |
|
141 | + elseif($field['type']=="text") { |
|
142 | + if(strlen($device[$field['name']])>0) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $device[$field['name']])."'>"; } |
|
143 | + else { print ""; } |
|
144 | + } |
|
145 | + else { |
|
146 | + print $device[$field['name']]; |
|
147 | + |
|
148 | + } |
|
149 | + print "</td>"; |
|
150 | + } |
|
151 | + } |
|
152 | + } |
|
153 | + |
|
154 | + print ' <td class="actions">'. "\n"; |
|
155 | + print " <div class='btn-group'>"; |
|
156 | + print " <button class='btn btn-xs btn-default editSwitch' data-action='edit' data-switchid='$device[id]'><i class='fa fa-pencil'></i></button>"; |
|
157 | + if($User->settings->enableSNMP=="1") |
|
158 | + print " <button class='btn btn-xs btn-default editSwitchSNMP' data-action='edit' data-switchid='$device[id]'><i class='fa fa-cogs'></i></button>"; |
|
159 | + print " <button class='btn btn-xs btn-default editSwitch' data-action='delete' data-switchid='$device[id]'><i class='fa fa-times'></i></button>"; |
|
160 | + print " </div>"; |
|
161 | + print ' </td>'. "\n"; |
|
162 | + |
|
163 | + print '</tr>'. "\n"; |
|
164 | + |
|
165 | + } |
|
166 | + print "</tbody>"; |
|
167 | + print '</table>'; |
|
168 | 168 | } |
169 | 169 | ?> |
170 | 170 |
@@ -42,23 +42,23 @@ |
||
42 | 42 | |
43 | 43 | # set snmp queries |
44 | 44 | foreach($_POST as $key=>$line) { |
45 | - if (strlen(strstr($key,"query-"))>0) { |
|
46 | - $key2 = str_replace("query-", "", $key); |
|
47 | - $temp[] = $key2; |
|
48 | - unset($_POST[$key]); |
|
49 | - } |
|
45 | + if (strlen(strstr($key,"query-"))>0) { |
|
46 | + $key2 = str_replace("query-", "", $key); |
|
47 | + $temp[] = $key2; |
|
48 | + unset($_POST[$key]); |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | # glue sections together |
52 | 52 | $_POST['snmp_queries'] = sizeof($temp)>0 ? implode(";", $temp) : null; |
53 | 53 | |
54 | 54 | # set update values |
55 | 55 | $values = array("id"=>$_POST['device_id'], |
56 | - "snmp_version"=>$_POST['snmp_version'], |
|
57 | - "snmp_community"=>$_POST['snmp_community'], |
|
58 | - "snmp_port"=>$_POST['snmp_port'], |
|
59 | - "snmp_timeout"=>$_POST['snmp_timeout'], |
|
60 | - "snmp_queries"=>$_POST['snmp_queries'] |
|
61 | - ); |
|
56 | + "snmp_version"=>$_POST['snmp_version'], |
|
57 | + "snmp_community"=>$_POST['snmp_community'], |
|
58 | + "snmp_port"=>$_POST['snmp_port'], |
|
59 | + "snmp_timeout"=>$_POST['snmp_timeout'], |
|
60 | + "snmp_queries"=>$_POST['snmp_queries'] |
|
61 | + ); |
|
62 | 62 | |
63 | 63 | # update device |
64 | 64 | if(!$Admin->object_modify("devices", "edit", "id", $values)) { $Result->show("danger", _("SNMP edit failed").'!', false); } |
@@ -122,15 +122,15 @@ |
||
122 | 122 | <td><?php print _('Queries'); ?></td> |
123 | 123 | <td style="text-align:top"> |
124 | 124 | <?php |
125 | - # select queries |
|
126 | - $queries = explode(";", $device->snmp_queries); |
|
127 | - $queries = is_array($queries) ? $queries : array(); |
|
125 | + # select queries |
|
126 | + $queries = explode(";", $device->snmp_queries); |
|
127 | + $queries = is_array($queries) ? $queries : array(); |
|
128 | 128 | // loop |
129 | - foreach($Snmp->snmp_queries as $k=>$m) { |
|
130 | - if(in_array($k, $queries)) { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="query-'. $k .'" value="on" checked> '. $k .'</div>'. "\n"; } |
|
131 | - else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="query-'. $k .'" value="on">'. $k .'</span></div>'. "\n"; } |
|
132 | - } |
|
133 | - ?> |
|
129 | + foreach($Snmp->snmp_queries as $k=>$m) { |
|
130 | + if(in_array($k, $queries)) { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="query-'. $k .'" value="on" checked> '. $k .'</div>'. "\n"; } |
|
131 | + else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="query-'. $k .'" value="on">'. $k .'</span></div>'. "\n"; } |
|
132 | + } |
|
133 | + ?> |
|
134 | 134 | </td> |
135 | 135 | </tr> |
136 | 136 |
@@ -29,12 +29,12 @@ discard block |
||
29 | 29 | |
30 | 30 | # available devices set |
31 | 31 | foreach($device as $key=>$line) { |
32 | - if (strlen(strstr($key,"section-"))>0) { |
|
33 | - $key2 = str_replace("section-", "", $key); |
|
34 | - $temp[] = $key2; |
|
32 | + if (strlen(strstr($key,"section-"))>0) { |
|
33 | + $key2 = str_replace("section-", "", $key); |
|
34 | + $temp[] = $key2; |
|
35 | 35 | |
36 | - unset($device[$key]); |
|
37 | - } |
|
36 | + unset($device[$key]); |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | # glue sections together |
40 | 40 | $device['sections'] = sizeof($temp)>0 ? implode(";", $temp) : null; |
@@ -61,33 +61,33 @@ discard block |
||
61 | 61 | # fetch custom fields |
62 | 62 | $custom = $Tools->fetch_custom_fields('devices'); |
63 | 63 | if(sizeof($custom) > 0) { |
64 | - foreach($custom as $myField) { |
|
65 | - //booleans can be only 0 and 1! |
|
66 | - if($myField['type']=="tinyint(1)") { |
|
67 | - if($device[$myField['name']]>1) { |
|
68 | - $device[$myField['name']] = 0; |
|
69 | - } |
|
70 | - } |
|
71 | - //not null! |
|
72 | - if($myField['Null']=="NO" && strlen($device[$myField['name']])==0) { |
|
73 | - { $Result->show("danger", $myField['name'].'" can not be empty!', true); } |
|
74 | - } |
|
75 | - # save to update array |
|
76 | - $update[$myField['name']] = $device[$myField['name']]; |
|
77 | - } |
|
64 | + foreach($custom as $myField) { |
|
65 | + //booleans can be only 0 and 1! |
|
66 | + if($myField['type']=="tinyint(1)") { |
|
67 | + if($device[$myField['name']]>1) { |
|
68 | + $device[$myField['name']] = 0; |
|
69 | + } |
|
70 | + } |
|
71 | + //not null! |
|
72 | + if($myField['Null']=="NO" && strlen($device[$myField['name']])==0) { |
|
73 | + { $Result->show("danger", $myField['name'].'" can not be empty!', true); } |
|
74 | + } |
|
75 | + # save to update array |
|
76 | + $update[$myField['name']] = $device[$myField['name']]; |
|
77 | + } |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | # set update values |
81 | 81 | $values = array("id"=>@$device['switchId'], |
82 | - "hostname"=>@$device['hostname'], |
|
83 | - "ip_addr"=>@$device['ip_addr'], |
|
84 | - "type"=>@$device['type'], |
|
85 | - "description"=>@$device['description'], |
|
86 | - "sections"=>@$device['sections'] |
|
87 | - ); |
|
82 | + "hostname"=>@$device['hostname'], |
|
83 | + "ip_addr"=>@$device['ip_addr'], |
|
84 | + "type"=>@$device['type'], |
|
85 | + "description"=>@$device['description'], |
|
86 | + "sections"=>@$device['sections'] |
|
87 | + ); |
|
88 | 88 | # custom fields |
89 | 89 | if(isset($update)) { |
90 | - $values = array_merge($values, $update); |
|
90 | + $values = array_merge($values, $update); |
|
91 | 91 | } |
92 | 92 | # rack |
93 | 93 | if (strlen(@$device['rack']>0)) { |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | else { $Result->show("success", _("Device $device[action] successfull").'!', false); } |
103 | 103 | |
104 | 104 | if($_POST['action']=="delete"){ |
105 | - # remove all references from subnets and ip addresses |
|
106 | - $Admin->remove_object_references ("subnets", "device", $values["id"]); |
|
107 | - $Admin->remove_object_references ("ipaddresses", "switch", $values["id"]); |
|
105 | + # remove all references from subnets and ip addresses |
|
106 | + $Admin->remove_object_references ("subnets", "device", $values["id"]); |
|
107 | + $Admin->remove_object_references ("ipaddresses", "switch", $values["id"]); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | ?> |
@@ -95,7 +95,7 @@ |
||
95 | 95 | $Result->show("Query result", implode("", $res), false, true, false, true); |
96 | 96 | } |
97 | 97 | else { |
98 | - $Result->show("warning", _("No queries"), false, true, false, true); |
|
98 | + $Result->show("warning", _("No queries"), false, true, false, true); |
|
99 | 99 | } |
100 | 100 | ?> |
101 | 101 |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | |
29 | 29 | # fetch device details |
30 | 30 | if( ($_POST['action'] == "edit") || ($_POST['action'] == "delete") ) { |
31 | - $device = (array) $Admin->fetch_object("devices", "id", $_POST['switchId']); |
|
32 | - // false |
|
33 | - if ($device===false) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
31 | + $device = (array) $Admin->fetch_object("devices", "id", $_POST['switchId']); |
|
32 | + // false |
|
33 | + if ($device===false) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | # set readonly flag |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | <td> |
89 | 89 | <select name="type" class="form-control input-sm input-w-auto"> |
90 | 90 | <?php |
91 | - $types = $Admin->fetch_all_objects("deviceTypes", "tid"); |
|
92 | - foreach($types as $name) { |
|
93 | - if($device['type'] == $name->tid) { print "<option value='$name->tid' selected='selected'>$name->tname</option>"; } |
|
94 | - else { print "<option value='$name->tid' >$name->tname</option>"; } |
|
95 | - } |
|
96 | - ?> |
|
91 | + $types = $Admin->fetch_all_objects("deviceTypes", "tid"); |
|
92 | + foreach($types as $name) { |
|
93 | + if($device['type'] == $name->tid) { print "<option value='$name->tid' selected='selected'>$name->tname</option>"; } |
|
94 | + else { print "<option value='$name->tid' >$name->tname</option>"; } |
|
95 | + } |
|
96 | + ?> |
|
97 | 97 | </select> |
98 | 98 | </td> |
99 | 99 | </tr> |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | <option value=""><?php print _("None"); ?></option> |
115 | 115 | <?php |
116 | 116 | foreach ($Racks->all_racks as $r) { |
117 | - if($device['rack'] == $r->id) { print "<option value='$r->id' selected='selected'>$r->name</option>"; } |
|
118 | - else { print "<option value='$r->id' >$r->name</option>"; } |
|
117 | + if($device['rack'] == $r->id) { print "<option value='$r->id' selected='selected'>$r->name</option>"; } |
|
118 | + else { print "<option value='$r->id' >$r->name</option>"; } |
|
119 | 119 | } |
120 | 120 | ?> |
121 | 121 | </select> |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | <td> |
159 | 159 | <textarea name="description" class="form-control input-sm" placeholder="<?php print _('Description'); ?>" <?php print $readonly; ?>><?php if(isset($device['description'])) print $device['description']; ?></textarea> |
160 | 160 | <?php |
161 | - if( ($_POST['action'] == "edit") || ($_POST['action'] == "delete") ) { |
|
162 | - print '<input type="hidden" name="switchId" value="'. $_POST['switchId'] .'">'. "\n"; |
|
163 | - } ?> |
|
161 | + if( ($_POST['action'] == "edit") || ($_POST['action'] == "delete") ) { |
|
162 | + print '<input type="hidden" name="switchId" value="'. $_POST['switchId'] .'">'. "\n"; |
|
163 | + } ?> |
|
164 | 164 | <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
165 | 165 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
166 | 166 | </td> |
@@ -168,101 +168,101 @@ discard block |
||
168 | 168 | |
169 | 169 | <!-- Custom --> |
170 | 170 | <?php |
171 | - if(sizeof($custom) > 0) { |
|
172 | - |
|
173 | - print '<tr>'; |
|
174 | - print ' <td colspan="2"><hr></td>'; |
|
175 | - print '</tr>'; |
|
176 | - |
|
177 | - # count datepickers |
|
178 | - $timeP = 0; |
|
179 | - |
|
180 | - # all my fields |
|
181 | - foreach($custom as $field) { |
|
182 | - # replace spaces with | |
|
183 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
184 | - |
|
185 | - # required |
|
186 | - if($field['Null']=="NO") { $required = "*"; } |
|
187 | - else { $required = ""; } |
|
188 | - |
|
189 | - # set default value ! |
|
190 | - if ($_POST['action']=="add") { $device[$field['name']] = $field['Default']; } |
|
191 | - |
|
192 | - print '<tr>'. "\n"; |
|
193 | - print ' <td>'. ucwords($field['name']) .' '.$required.'</td>'. "\n"; |
|
194 | - print ' <td>'. "\n"; |
|
195 | - |
|
196 | - //set type |
|
197 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
198 | - //parse values |
|
199 | - $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
200 | - //null |
|
201 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
202 | - |
|
203 | - print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
204 | - foreach($tmp as $v) { |
|
205 | - if($v==$device[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
206 | - else { print "<option value='$v'>$v</option>"; } |
|
207 | - } |
|
208 | - print "</select>"; |
|
209 | - } |
|
210 | - //date and time picker |
|
211 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
212 | - // just for first |
|
213 | - if($timeP==0) { |
|
214 | - print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
215 | - print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
216 | - print '<script type="text/javascript">'; |
|
217 | - print '$(document).ready(function() {'; |
|
218 | - //date only |
|
219 | - print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
220 | - //date + time |
|
221 | - print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
222 | - |
|
223 | - print '})'; |
|
224 | - print '</script>'; |
|
225 | - } |
|
226 | - $timeP++; |
|
227 | - |
|
228 | - //set size |
|
229 | - if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
230 | - else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
231 | - |
|
232 | - //field |
|
233 | - if(!isset($device[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
234 | - else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $device[$field['name']]. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
235 | - } |
|
236 | - //boolean |
|
237 | - elseif($field['type'] == "tinyint(1)") { |
|
238 | - print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
239 | - $tmp = array(0=>"No",1=>"Yes"); |
|
240 | - //null |
|
241 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
242 | - |
|
243 | - foreach($tmp as $k=>$v) { |
|
244 | - if(strlen($device[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
245 | - elseif($k==$device[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
246 | - else { print "<option value='$k'>"._($v)."</option>"; } |
|
247 | - } |
|
248 | - print "</select>"; |
|
249 | - } |
|
250 | - //text |
|
251 | - elseif($field['type'] == "text") { |
|
252 | - print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. $device[$field['name']]. '</textarea>'. "\n"; |
|
253 | - } |
|
254 | - //default - input field |
|
255 | - else { |
|
256 | - print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. $device[$field['name']]. '" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
257 | - } |
|
258 | - |
|
259 | - print ' </td>'. "\n"; |
|
260 | - print '</tr>'. "\n"; |
|
261 | - } |
|
262 | - |
|
263 | - } |
|
264 | - |
|
265 | - ?> |
|
171 | + if(sizeof($custom) > 0) { |
|
172 | + |
|
173 | + print '<tr>'; |
|
174 | + print ' <td colspan="2"><hr></td>'; |
|
175 | + print '</tr>'; |
|
176 | + |
|
177 | + # count datepickers |
|
178 | + $timeP = 0; |
|
179 | + |
|
180 | + # all my fields |
|
181 | + foreach($custom as $field) { |
|
182 | + # replace spaces with | |
|
183 | + $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
184 | + |
|
185 | + # required |
|
186 | + if($field['Null']=="NO") { $required = "*"; } |
|
187 | + else { $required = ""; } |
|
188 | + |
|
189 | + # set default value ! |
|
190 | + if ($_POST['action']=="add") { $device[$field['name']] = $field['Default']; } |
|
191 | + |
|
192 | + print '<tr>'. "\n"; |
|
193 | + print ' <td>'. ucwords($field['name']) .' '.$required.'</td>'. "\n"; |
|
194 | + print ' <td>'. "\n"; |
|
195 | + |
|
196 | + //set type |
|
197 | + if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
198 | + //parse values |
|
199 | + $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
200 | + //null |
|
201 | + if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
202 | + |
|
203 | + print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
204 | + foreach($tmp as $v) { |
|
205 | + if($v==$device[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
206 | + else { print "<option value='$v'>$v</option>"; } |
|
207 | + } |
|
208 | + print "</select>"; |
|
209 | + } |
|
210 | + //date and time picker |
|
211 | + elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
212 | + // just for first |
|
213 | + if($timeP==0) { |
|
214 | + print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
215 | + print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
216 | + print '<script type="text/javascript">'; |
|
217 | + print '$(document).ready(function() {'; |
|
218 | + //date only |
|
219 | + print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
220 | + //date + time |
|
221 | + print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
222 | + |
|
223 | + print '})'; |
|
224 | + print '</script>'; |
|
225 | + } |
|
226 | + $timeP++; |
|
227 | + |
|
228 | + //set size |
|
229 | + if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
230 | + else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
231 | + |
|
232 | + //field |
|
233 | + if(!isset($device[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
234 | + else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $device[$field['name']]. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
235 | + } |
|
236 | + //boolean |
|
237 | + elseif($field['type'] == "tinyint(1)") { |
|
238 | + print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
239 | + $tmp = array(0=>"No",1=>"Yes"); |
|
240 | + //null |
|
241 | + if($field['Null']!="NO") { $tmp[2] = ""; } |
|
242 | + |
|
243 | + foreach($tmp as $k=>$v) { |
|
244 | + if(strlen($device[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
245 | + elseif($k==$device[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
246 | + else { print "<option value='$k'>"._($v)."</option>"; } |
|
247 | + } |
|
248 | + print "</select>"; |
|
249 | + } |
|
250 | + //text |
|
251 | + elseif($field['type'] == "text") { |
|
252 | + print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. $device[$field['name']]. '</textarea>'. "\n"; |
|
253 | + } |
|
254 | + //default - input field |
|
255 | + else { |
|
256 | + print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. $device[$field['name']]. '" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
257 | + } |
|
258 | + |
|
259 | + print ' </td>'. "\n"; |
|
260 | + print '</tr>'. "\n"; |
|
261 | + } |
|
262 | + |
|
263 | + } |
|
264 | + |
|
265 | + ?> |
|
266 | 266 | |
267 | 267 | <!-- Sections --> |
268 | 268 | <tr> |
@@ -277,21 +277,21 @@ discard block |
||
277 | 277 | <td></td> |
278 | 278 | <td> |
279 | 279 | <?php |
280 | - # select sections |
|
281 | - $Sections = new Sections ($Database); |
|
282 | - $sections = $Sections->fetch_all_sections(); |
|
283 | - |
|
284 | - # reformat device sections to array |
|
285 | - $deviceSections = explode(";", $device['sections']); |
|
286 | - $deviceSections = is_array($deviceSections) ? $deviceSections : array(); |
|
287 | - |
|
288 | - if ($sections!==false) { |
|
289 | - foreach($sections as $section) { |
|
290 | - if(in_array($section->id, $deviceSections)) { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on" checked> '. $section->name .'</div>'. "\n"; } |
|
291 | - else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on">'. $section->name .'</span></div>'. "\n"; } |
|
292 | - } |
|
293 | - } |
|
294 | - ?> |
|
280 | + # select sections |
|
281 | + $Sections = new Sections ($Database); |
|
282 | + $sections = $Sections->fetch_all_sections(); |
|
283 | + |
|
284 | + # reformat device sections to array |
|
285 | + $deviceSections = explode(";", $device['sections']); |
|
286 | + $deviceSections = is_array($deviceSections) ? $deviceSections : array(); |
|
287 | + |
|
288 | + if ($sections!==false) { |
|
289 | + foreach($sections as $section) { |
|
290 | + if(in_array($section->id, $deviceSections)) { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on" checked> '. $section->name .'</div>'. "\n"; } |
|
291 | + else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on">'. $section->name .'</span></div>'. "\n"; } |
|
292 | + } |
|
293 | + } |
|
294 | + ?> |
|
295 | 295 | </td> |
296 | 296 | </tr> |
297 | 297 |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | $expfields = explode("|",$_GET['expfields']); |
18 | 18 | $reqfields = explode("|",$_GET['reqfields']); |
19 | 19 | if (isset($_GET['filetype'])) { |
20 | - $filetype = $_GET['filetype']; |
|
20 | + $filetype = $_GET['filetype']; |
|
21 | 21 | } else { |
22 | - $Result->show('danger', _("Error: could not read the uploaded file type!"), true, true); |
|
22 | + $Result->show('danger', _("Error: could not read the uploaded file type!"), true, true); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | # Load colors and icons |
@@ -30,87 +30,87 @@ discard block |
||
30 | 30 | |
31 | 31 | # read field mapping from previous window |
32 | 32 | foreach ($expfields as $expfield) { |
33 | - if (isset($_GET['importFields__'.str_replace(" ", "_",$expfield)])) { |
|
34 | - $impfield = $_GET['importFields__'.str_replace(" ", "_",$expfield)]; |
|
35 | - if (in_array($expfield,$reqfields) && ($impfield == "-")) { |
|
36 | - $Result->show('danger', _("Error: missing required field mapping for expected field")." <b>".$expfield."</b>."._("Please check field matching in previous window."), true, true); |
|
37 | - } else { |
|
38 | - if ($impfield != "-") { $impfields[$impfield] = $expfield; } |
|
39 | - } |
|
40 | - } else { |
|
41 | - $Result->show('danger', _("Internal error: missing import field mapping."), true, true); |
|
42 | - } |
|
43 | - # prepare header row for preview table |
|
44 | - $hrow.="<th>".$expfield."</th>"; |
|
45 | - # prepare select field to transfer to actual import file |
|
46 | - $hiddenfields.="<input name='importFields__".str_replace(" ", "_",$expfield)."' type='hidden' value='".$impfield."' style='display:none;'>"; |
|
33 | + if (isset($_GET['importFields__'.str_replace(" ", "_",$expfield)])) { |
|
34 | + $impfield = $_GET['importFields__'.str_replace(" ", "_",$expfield)]; |
|
35 | + if (in_array($expfield,$reqfields) && ($impfield == "-")) { |
|
36 | + $Result->show('danger', _("Error: missing required field mapping for expected field")." <b>".$expfield."</b>."._("Please check field matching in previous window."), true, true); |
|
37 | + } else { |
|
38 | + if ($impfield != "-") { $impfields[$impfield] = $expfield; } |
|
39 | + } |
|
40 | + } else { |
|
41 | + $Result->show('danger', _("Internal error: missing import field mapping."), true, true); |
|
42 | + } |
|
43 | + # prepare header row for preview table |
|
44 | + $hrow.="<th>".$expfield."</th>"; |
|
45 | + # prepare select field to transfer to actual import file |
|
46 | + $hiddenfields.="<input name='importFields__".str_replace(" ", "_",$expfield)."' type='hidden' value='".$impfield."' style='display:none;'>"; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | $data = array(); |
50 | 50 | |
51 | 51 | # read first row from CSV |
52 | 52 | if (strtolower($filetype) == "csv") { |
53 | - # open CSV file |
|
54 | - $filehdl = fopen('upload/data_import.csv', 'r'); |
|
53 | + # open CSV file |
|
54 | + $filehdl = fopen('upload/data_import.csv', 'r'); |
|
55 | 55 | |
56 | - # read header row |
|
57 | - $row = 0;$col = 0; |
|
58 | - $line = fgets($filehdl); |
|
59 | - $row++; |
|
60 | - $line = str_replace( array("\r\n","\r") , "" , $line); //remove line break |
|
61 | - $cols = preg_split("/[;]/", $line); //split by comma or semi-colon |
|
62 | - foreach ($cols as $val) { |
|
63 | - $col++; |
|
64 | - # map import columns to expected fields as per previous window |
|
65 | - $fieldmap[$col] = $impfields[$val]; |
|
66 | - $hcol = $col; |
|
67 | - } |
|
56 | + # read header row |
|
57 | + $row = 0;$col = 0; |
|
58 | + $line = fgets($filehdl); |
|
59 | + $row++; |
|
60 | + $line = str_replace( array("\r\n","\r") , "" , $line); //remove line break |
|
61 | + $cols = preg_split("/[;]/", $line); //split by comma or semi-colon |
|
62 | + foreach ($cols as $val) { |
|
63 | + $col++; |
|
64 | + # map import columns to expected fields as per previous window |
|
65 | + $fieldmap[$col] = $impfields[$val]; |
|
66 | + $hcol = $col; |
|
67 | + } |
|
68 | 68 | |
69 | - # read each remaining row into a dictionary with expected fields as keys |
|
70 | - while (($line = fgets($filehdl)) !== false) { |
|
71 | - $row++;$col = 0; |
|
72 | - $line = str_replace( array("\r\n","\r") , "" , $line); //remove line break |
|
73 | - $cols = preg_split("/[;]/", $line); //split by comma or semi-colon |
|
74 | - $record = array(); |
|
75 | - foreach ($cols as $val) { |
|
76 | - $col++; |
|
77 | - if ($col > $hcol) { |
|
78 | - $Result->show('danger', _("Extra column found on line ").$row._(" in CSV file. CSV delimiter used in value field?"), true); |
|
79 | - } else { |
|
80 | - # read each row into a dictionary with expected fields as keys |
|
81 | - $record[$fieldmap[$col]] = trim($val); |
|
82 | - } |
|
83 | - } |
|
84 | - $data[] = $record; |
|
85 | - } |
|
86 | - fclose($filehdl); |
|
69 | + # read each remaining row into a dictionary with expected fields as keys |
|
70 | + while (($line = fgets($filehdl)) !== false) { |
|
71 | + $row++;$col = 0; |
|
72 | + $line = str_replace( array("\r\n","\r") , "" , $line); //remove line break |
|
73 | + $cols = preg_split("/[;]/", $line); //split by comma or semi-colon |
|
74 | + $record = array(); |
|
75 | + foreach ($cols as $val) { |
|
76 | + $col++; |
|
77 | + if ($col > $hcol) { |
|
78 | + $Result->show('danger', _("Extra column found on line ").$row._(" in CSV file. CSV delimiter used in value field?"), true); |
|
79 | + } else { |
|
80 | + # read each row into a dictionary with expected fields as keys |
|
81 | + $record[$fieldmap[$col]] = trim($val); |
|
82 | + } |
|
83 | + } |
|
84 | + $data[] = $record; |
|
85 | + } |
|
86 | + fclose($filehdl); |
|
87 | 87 | } |
88 | 88 | # read first row from XLS |
89 | 89 | elseif(strtolower($filetype) == "xls") { |
90 | - # get excel object |
|
91 | - require_once(dirname(__FILE__) . '/../../../functions/php-excel-reader/excel_reader2.php'); //excel reader 2.21 |
|
92 | - $xls = new Spreadsheet_Excel_Reader('upload/data_import.xls', false); |
|
93 | - $sheet = 0; $row = 1; |
|
90 | + # get excel object |
|
91 | + require_once(dirname(__FILE__) . '/../../../functions/php-excel-reader/excel_reader2.php'); //excel reader 2.21 |
|
92 | + $xls = new Spreadsheet_Excel_Reader('upload/data_import.xls', false); |
|
93 | + $sheet = 0; $row = 1; |
|
94 | 94 | |
95 | - # map import columns to expected fields as per previous window |
|
96 | - for($col=1;$col<=$xls->colcount($sheet);$col++) { |
|
97 | - $fieldmap[$col] = $impfields[$xls->val($row,$col,$sheet)]; |
|
98 | - $hcol = $col; |
|
99 | - } |
|
95 | + # map import columns to expected fields as per previous window |
|
96 | + for($col=1;$col<=$xls->colcount($sheet);$col++) { |
|
97 | + $fieldmap[$col] = $impfields[$xls->val($row,$col,$sheet)]; |
|
98 | + $hcol = $col; |
|
99 | + } |
|
100 | 100 | |
101 | - # read each remaining row into a dictionary with expected fields as keys |
|
102 | - for($row=2;$row<=$xls->rowcount($sheet);$row++) { |
|
103 | - $record = array(); |
|
104 | - for($col=1;$col<=$xls->colcount($sheet);$col++) { |
|
105 | - $record++; |
|
106 | - if ($col > $hcol) { |
|
107 | - $Result->show('danger', _("Extra column found on line ").$row._(" in XLS file. Please check input file."), true); |
|
108 | - } else { |
|
109 | - $record[$fieldmap[$col]] = trim($xls->val($row,$col,$sheet)); |
|
110 | - } |
|
111 | - } |
|
112 | - $data[] = $record; |
|
113 | - } |
|
101 | + # read each remaining row into a dictionary with expected fields as keys |
|
102 | + for($row=2;$row<=$xls->rowcount($sheet);$row++) { |
|
103 | + $record = array(); |
|
104 | + for($col=1;$col<=$xls->colcount($sheet);$col++) { |
|
105 | + $record++; |
|
106 | + if ($col > $hcol) { |
|
107 | + $Result->show('danger', _("Extra column found on line ").$row._(" in XLS file. Please check input file."), true); |
|
108 | + } else { |
|
109 | + $record[$fieldmap[$col]] = trim($xls->val($row,$col,$sheet)); |
|
110 | + } |
|
111 | + } |
|
112 | + $data[] = $record; |
|
113 | + } |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | ?> |
117 | 117 | \ No newline at end of file |
@@ -48,33 +48,33 @@ discard block |
||
48 | 48 | |
49 | 49 | //write headers |
50 | 50 | if( (isset($_GET['name'])) && ($_GET['name'] == "on") ) { |
51 | - $worksheet->write($lineCount, $rowCount, _('Name') ,$format_header); |
|
52 | - $rowCount++; |
|
51 | + $worksheet->write($lineCount, $rowCount, _('Name') ,$format_header); |
|
52 | + $rowCount++; |
|
53 | 53 | } |
54 | 54 | if( (isset($_GET['number'])) && ($_GET['number'] == "on") ) { |
55 | - $worksheet->write($lineCount, $rowCount, _('Number') ,$format_header); |
|
56 | - $rowCount++; |
|
55 | + $worksheet->write($lineCount, $rowCount, _('Number') ,$format_header); |
|
56 | + $rowCount++; |
|
57 | 57 | } |
58 | 58 | if( (isset($_GET['domain'])) && ($_GET['domain'] == "on") ) { |
59 | - $worksheet->write($lineCount, $rowCount, _('Domain') ,$format_header); |
|
60 | - $rowCount++; |
|
59 | + $worksheet->write($lineCount, $rowCount, _('Domain') ,$format_header); |
|
60 | + $rowCount++; |
|
61 | 61 | } |
62 | 62 | if( (isset($_GET['description'])) && ($_GET['description'] == "on") ) { |
63 | - $worksheet->write($lineCount, $rowCount, _('Description') ,$format_header); |
|
64 | - $rowCount++; |
|
63 | + $worksheet->write($lineCount, $rowCount, _('Description') ,$format_header); |
|
64 | + $rowCount++; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | //custom fields |
68 | 68 | if(sizeof($custom_fields) > 0) { |
69 | - foreach($custom_fields as $myField) { |
|
70 | - //set temp name - replace space with three ___ |
|
71 | - $myField['nameTemp'] = str_replace(" ", "___", $myField['name']); |
|
72 | - |
|
73 | - if( (isset($_GET[$myField['nameTemp']])) && ($_GET[$myField['nameTemp']] == "on") ) { |
|
74 | - $worksheet->write($lineCount, $rowCount, $myField['name'] ,$format_header); |
|
75 | - $rowCount++; |
|
76 | - } |
|
77 | - } |
|
69 | + foreach($custom_fields as $myField) { |
|
70 | + //set temp name - replace space with three ___ |
|
71 | + $myField['nameTemp'] = str_replace(" ", "___", $myField['name']); |
|
72 | + |
|
73 | + if( (isset($_GET[$myField['nameTemp']])) && ($_GET[$myField['nameTemp']] == "on") ) { |
|
74 | + $worksheet->write($lineCount, $rowCount, $myField['name'] ,$format_header); |
|
75 | + $rowCount++; |
|
76 | + } |
|
77 | + } |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
@@ -82,56 +82,56 @@ discard block |
||
82 | 82 | |
83 | 83 | //write Subnet entries for the selected sections |
84 | 84 | foreach ($vlan_domains as $vlan_domain) { |
85 | - //cast |
|
86 | - $vlan_domain = (array) $vlan_domain; |
|
87 | - |
|
88 | - if( (isset($_GET['exportDomain__'.str_replace(" ", "_",$vlan_domain['name'])])) && ($_GET['exportDomain__'.str_replace(" ", "_",$vlan_domain['name'])] == "on") ) { |
|
89 | - // get all VLANs in VLAN domain |
|
90 | - $all_vlans = $Admin->fetch_multiple_objects("vlans", "domainId", $vlan_domain['id'], "number"); |
|
91 | - $all_vlans = (array) $all_vlans; |
|
92 | - // skip empty domains |
|
93 | - if (sizeof($all_vlans)==0) { continue; } |
|
94 | - //write all VLAN entries |
|
95 | - foreach ($all_vlans as $vlan) { |
|
96 | - //cast |
|
97 | - $vlan = (array) $vlan; |
|
98 | - |
|
99 | - //reset row count |
|
100 | - $rowCount = 0; |
|
101 | - |
|
102 | - if( (isset($_GET['name'])) && ($_GET['name'] == "on") ) { |
|
103 | - $worksheet->write($lineCount, $rowCount, $vlan['name'], $format_text); |
|
104 | - $rowCount++; |
|
105 | - } |
|
106 | - if( (isset($_GET['number'])) && ($_GET['number'] == "on") ) { |
|
107 | - $worksheet->write($lineCount, $rowCount, $vlan['number'], $format_text); |
|
108 | - $rowCount++; |
|
109 | - } |
|
110 | - if( (isset($_GET['domain'])) && ($_GET['domain'] == "on") ) { |
|
111 | - $worksheet->write($lineCount, $rowCount, $vlan_domain['name'], $format_text); |
|
112 | - $rowCount++; |
|
113 | - } |
|
114 | - if( (isset($_GET['description'])) && ($_GET['description'] == "on") ) { |
|
115 | - $worksheet->write($lineCount, $rowCount, $vlan['description'], $format_text); |
|
116 | - $rowCount++; |
|
117 | - } |
|
118 | - |
|
119 | - //custom fields, per VLAN |
|
120 | - if(sizeof($custom_fields) > 0) { |
|
121 | - foreach($custom_fields as $myField) { |
|
122 | - //set temp name - replace space with three ___ |
|
123 | - $myField['nameTemp'] = str_replace(" ", "___", $myField['name']); |
|
124 | - |
|
125 | - if( (isset($_GET[$myField['nameTemp']])) && ($_GET[$myField['nameTemp']] == "on") ) { |
|
126 | - $worksheet->write($lineCount, $rowCount, $vlan[$myField['name']], $format_text); |
|
127 | - $rowCount++; |
|
128 | - } |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - $lineCount++; |
|
133 | - } |
|
134 | - } |
|
85 | + //cast |
|
86 | + $vlan_domain = (array) $vlan_domain; |
|
87 | + |
|
88 | + if( (isset($_GET['exportDomain__'.str_replace(" ", "_",$vlan_domain['name'])])) && ($_GET['exportDomain__'.str_replace(" ", "_",$vlan_domain['name'])] == "on") ) { |
|
89 | + // get all VLANs in VLAN domain |
|
90 | + $all_vlans = $Admin->fetch_multiple_objects("vlans", "domainId", $vlan_domain['id'], "number"); |
|
91 | + $all_vlans = (array) $all_vlans; |
|
92 | + // skip empty domains |
|
93 | + if (sizeof($all_vlans)==0) { continue; } |
|
94 | + //write all VLAN entries |
|
95 | + foreach ($all_vlans as $vlan) { |
|
96 | + //cast |
|
97 | + $vlan = (array) $vlan; |
|
98 | + |
|
99 | + //reset row count |
|
100 | + $rowCount = 0; |
|
101 | + |
|
102 | + if( (isset($_GET['name'])) && ($_GET['name'] == "on") ) { |
|
103 | + $worksheet->write($lineCount, $rowCount, $vlan['name'], $format_text); |
|
104 | + $rowCount++; |
|
105 | + } |
|
106 | + if( (isset($_GET['number'])) && ($_GET['number'] == "on") ) { |
|
107 | + $worksheet->write($lineCount, $rowCount, $vlan['number'], $format_text); |
|
108 | + $rowCount++; |
|
109 | + } |
|
110 | + if( (isset($_GET['domain'])) && ($_GET['domain'] == "on") ) { |
|
111 | + $worksheet->write($lineCount, $rowCount, $vlan_domain['name'], $format_text); |
|
112 | + $rowCount++; |
|
113 | + } |
|
114 | + if( (isset($_GET['description'])) && ($_GET['description'] == "on") ) { |
|
115 | + $worksheet->write($lineCount, $rowCount, $vlan['description'], $format_text); |
|
116 | + $rowCount++; |
|
117 | + } |
|
118 | + |
|
119 | + //custom fields, per VLAN |
|
120 | + if(sizeof($custom_fields) > 0) { |
|
121 | + foreach($custom_fields as $myField) { |
|
122 | + //set temp name - replace space with three ___ |
|
123 | + $myField['nameTemp'] = str_replace(" ", "___", $myField['name']); |
|
124 | + |
|
125 | + if( (isset($_GET[$myField['nameTemp']])) && ($_GET[$myField['nameTemp']] == "on") ) { |
|
126 | + $worksheet->write($lineCount, $rowCount, $vlan[$myField['name']], $format_text); |
|
127 | + $rowCount++; |
|
128 | + } |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + $lineCount++; |
|
133 | + } |
|
134 | + } |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | //new line |
@@ -139,35 +139,35 @@ discard block |
||
139 | 139 | |
140 | 140 | //write domain sheet |
141 | 141 | if( (isset($_GET['exportVLANDomains'])) && ($_GET['exportVLANDomains'] == "on") ) { |
142 | - // Create a worksheet |
|
143 | - $worksheet_domains =& $workbook->addWorksheet('Domains'); |
|
144 | - |
|
145 | - $lineCount = 0; |
|
146 | - $rowCount = 0; |
|
147 | - |
|
148 | - //write headers |
|
149 | - $worksheet_domains->write($lineCount, $rowCount, _('Name') ,$format_header); |
|
150 | - $rowCount++; |
|
151 | - $worksheet_domains->write($lineCount, $rowCount, _('Description') ,$format_header); |
|
152 | - $rowCount++; |
|
153 | - |
|
154 | - $lineCount++; |
|
155 | - $rowCount = 0; |
|
156 | - |
|
157 | - foreach ($vlan_domains as $vlan_domain) { |
|
158 | - //cast |
|
159 | - $vlan_domain = (array) $vlan_domain; |
|
160 | - |
|
161 | - if( (isset($_GET['exportDomain__'.str_replace(" ", "_",$vlan_domain['name'])])) && ($_GET['exportDomain__'.str_replace(" ", "_",$vlan_domain['name'])] == "on") ) { |
|
162 | - $worksheet_domains->write($lineCount, $rowCount, $vlan_domain['name'], $format_text); |
|
163 | - $rowCount++; |
|
164 | - $worksheet_domains->write($lineCount, $rowCount, $vlan_domain['description'], $format_text); |
|
165 | - $rowCount++; |
|
166 | - } |
|
167 | - |
|
168 | - $lineCount++; |
|
169 | - $rowCount = 0; |
|
170 | - } |
|
142 | + // Create a worksheet |
|
143 | + $worksheet_domains =& $workbook->addWorksheet('Domains'); |
|
144 | + |
|
145 | + $lineCount = 0; |
|
146 | + $rowCount = 0; |
|
147 | + |
|
148 | + //write headers |
|
149 | + $worksheet_domains->write($lineCount, $rowCount, _('Name') ,$format_header); |
|
150 | + $rowCount++; |
|
151 | + $worksheet_domains->write($lineCount, $rowCount, _('Description') ,$format_header); |
|
152 | + $rowCount++; |
|
153 | + |
|
154 | + $lineCount++; |
|
155 | + $rowCount = 0; |
|
156 | + |
|
157 | + foreach ($vlan_domains as $vlan_domain) { |
|
158 | + //cast |
|
159 | + $vlan_domain = (array) $vlan_domain; |
|
160 | + |
|
161 | + if( (isset($_GET['exportDomain__'.str_replace(" ", "_",$vlan_domain['name'])])) && ($_GET['exportDomain__'.str_replace(" ", "_",$vlan_domain['name'])] == "on") ) { |
|
162 | + $worksheet_domains->write($lineCount, $rowCount, $vlan_domain['name'], $format_text); |
|
163 | + $rowCount++; |
|
164 | + $worksheet_domains->write($lineCount, $rowCount, $vlan_domain['description'], $format_text); |
|
165 | + $rowCount++; |
|
166 | + } |
|
167 | + |
|
168 | + $lineCount++; |
|
169 | + $rowCount = 0; |
|
170 | + } |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // sending HTTP headers |