-
Notifications
You must be signed in to change notification settings - Fork 3
/
templates.php
172 lines (159 loc) · 6.98 KB
/
templates.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
session_start();
$selectedPage="configure";
include "class/db.class.php";
$globalTopic = "Templates Listing"; // page title
$templates = new templates; // declare class object
if (isset($_GET['id']) && isset($_GET['mode']) && $_GET['mode'] == 'delete') // link actions
{
if(is_numeric($_GET['id']))
{
$templates->delete($_GET['id']);
header("Location: templates.php");
}
else
header("Location: templates.php?error=invalidID");
}
include "theme/" . $theme . "/top.php";
?>
<div id="main">
<div id="left">
<div class="module" id="templates">
<strong>Device Templates</strong>
<p>
All devices within RackSmith link back to a template, this essentially relates to the model of the device.
<br/>
Here you can create and manage all the templates which are later used when you create devices.
</p><p><a href="manageTemplates.php">Create a new Template</a></p><i>Select a device type to view templates</i>
<?php
$deviceTypes = new deviceTypes;
$typeListing=$deviceTypes->getAll();
$cachedTemplates=array();
?>
<div id="deviceTypeListing" class="listObjects" >
<ul>
<?php
foreach($typeListing as $type)
{
$cachedTemplates[$type->deviceTypeID]=$templates->getByDeviceType($type->deviceTypeID);
$count=0;
if(is_array($cachedTemplates[$type->deviceTypeID]))
$count=count($cachedTemplates[$type->deviceTypeID]);
echo "<li style='display:inline-block;margin-right:10px;' alt='deviceType".$type->deviceTypeID."' onclick=\"$(this).toggleClass('highlighted');$('#templateType".$type->deviceTypeID."').slideToggle('fast');\"><div class='name' >".$type->name;
if($count)
echo " (".$count.")";
echo "</div></li>";
}
?>
</ul>
</div>
<?php
foreach($typeListing as $type)
{
?>
<p>
<div class="templateTable" id="templateType<?php echo $type->deviceTypeID; ?>" style="display:none;">
<table width="100%" class="dataTable">
<colgroup align="left" class="tblfirstRow"></colgroup>
<thead>
<tr>
<th scope="col" width='25%'>Model</th>
<th scope="col" width='10%'>Vendor</th>
<th scope="col" width='33%'>Positioning</th>
<th scope="col" width='7%' >Ports</th>
<th scope="col" width="15%">Options</th>
</tr>
</thead>
<tbody>
<?php
// Loop Through Owners
//$listType = $templates->getByDeviceType($type->deviceTypeID);
$listType=$cachedTemplates[$type->deviceTypeID];
if($listType)
{
foreach($listType as $template)
{
$template->fillCategories(1,1,array(GENERIC,RACK_MOUNTABLE,FLOOR_DEVICE,OUTDOOR_ITEM));
if($template->deleted==0)
{
$portCount=$template->numPorts();
if(!is_numeric($portCount))
$portCount=0;
?>
<tr>
<td><b><?php echo $template->name; ?></b></td>
<td><?php echo $template->getMeta(12,1); ?></td>
<td>
<?php
$position=array();
if(isset($template->categories[RACK_MOUNTABLE]))
$position[]="Rack Mount (".$template->categories[RACK_MOUNTABLE][5]->value."RU)";
if(isset($template->categories[FLOOR_DEVICE]))
$position[]="Floor Item";
if(isset($template->categories[OUTDOOR_ITEM]))
$position[]="Outdoor Item";
echo implode(", ", $position);
?>
</td>
<td align="right"><?php echo $portCount; ?></td>
<td align="center">
<a href="editTemplates.php?mode=edit&id=<?php echo $template->templateID; ?>">Edit</a> |
<a href="#" onclick="if (confirm('Are you sure you want to delete this template? \nIt will still be available for existing items')) { location.href = 'templates.php?action=template&mode=delete&id=<?php echo $template->templateID; ?>'; } ">Delete</a>
</td>
</tr>
<?php
}
}
}
?>
</tbody>
<tfoot>
<tr>
<td colspan="5" style="padding-left:10px;">
<a href="manageTemplates.php?deviceType=<?php echo $type->deviceTypeID;?>" >Create a new <?php echo $type->name;?> template</a>
</td>
</table>
</div>
<?php
}?>
</p>
</div>
</div>
<div id="right">
<div class="module sideMenu">
<strong>Devices & Templates</strong>
<p>
<ul>
<li><a href="manageTemplates.php">Create a new Template</a></li>
<li><a href="templates.php">Templates List</a></li>
<li><a href="templateMover.php">Import/Export Templates</a></li>
<li><a href="metadata.php" >Device Information</a></li>
</ul>
</p>
</div>
<div class="module sideMenu">
<strong>System</strong>
<p>
<ul>
<li><a href="cables.php" >Cable Types</a></li>
<li><a href="owners.php" >Equipment Owners</a></li>
<li><a href="management.php?action=accounts" >User Accounts</a></li>
<li><a href="system.php" >System</a></li>
<li><a href="logs.php" >Logs</a></li>
<li><a href="templateMover.php" >Import / Export Templates</a></li>
</ul>
</p>
</div>
<?php
if(isset($_GET['error']) && $_GET['error'] == "templateNotFound")
echo "<div class='module error' >The template you requested could not be found</div>";
if(isset($_GET['insert']) && $_GET['insert'] == 'Success')
echo '<div class="module" ><div class="success" >Created Template!</div></div>';
if(isset($_GET['update']) && $_GET['update'] == 'Success')
echo '<div class="module" ><div class="success" >Updated Template!</div></div>';
?>
</div>
</div>
<?php
include "theme/" . $theme . "/base.php";
?>