-
Notifications
You must be signed in to change notification settings - Fork 205
/
bulk_importer.php
570 lines (476 loc) · 23.8 KB
/
bulk_importer.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
<?php
require_once "db.inc.php";
require_once "facilities.inc.php";
if(!$person->BulkOperations){
header('Location: '.redirect());
exit;
}
// Uncomment these if you need/want to set a title in the header
// $header=__("");
$subheader=__("Bulk Device Importer");
$content = "";
if ( isset( $_FILES['inputfile'] )) {
//
// File name has been specified, so we're uploading a new file. Need to simply make sure
// that it's at least a valid file that PHPExcel can open and that we can move it to
// the /tmp directory. We'll set the filename as a session variable so that we can keep track
// of it more simply as we move from stage to stage.
//
$target_dir = '/tmp/';
$targetFile = $target_dir . basename($_FILES['inputfile']['name']);
try {
$inFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($_FILES['inputfile']['tmp_name']);
$objReader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inFileType);
$objXL = $objReader->load($_FILES['inputfile']['tmp_name']);
} catch (Exception $e) {
die("Error opening file: ".$e->getMessage());
}
move_uploaded_file( $_FILES['inputfile']['tmp_name'], $targetFile );
$_SESSION['inputfile'] = $targetFile;
echo "<meta http-equiv='refresh' content='0; url=" . $_SERVER['SCRIPT_NAME'] . "?stage=headers'>";
exit;
} elseif ( isset( $_REQUEST['stage'] ) && $_REQUEST['stage'] == 'headers' ) {
//
// File has been moved, so now we're ready to map out the columns to fields for processing.
// If you don't want to have to map every time, you can simply make your spreadsheet columns
// appear in the same order as they show up on this page. That way you can just click right
// on to the next stage, which is validation.
//
// Make sure that we can still access the file
$targetFile = $_SESSION['inputfile'];
try {
$inFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($targetFile);
$objReader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inFileType);
$objXL = $objReader->load($targetFile);
} catch (Exception $e) {
die("Error opening file: ".$e->getMessage());
}
// We're good, so now get the top row so that we can map it out to fields
$content = "<h3>" . __("Pick the appropriate column header (line 1) for each field name listed below." ) . "</h3>";
$content .= "<h3>" . __("Mouse over each field for help text.") . "</h3>";
$content .= '<form method="POST">
<input type="hidden" name="stage" value="validate">
<div class="table">';
// Find out how many columns are in the spreadsheet so that we can load them as possible values for the fields
// and we don't really care how many rows there are at this point.
$sheet = $objXL->getSheet(0);
$highestColumn = $sheet->getHighestColumn();
$headerList = $sheet->rangeToArray('A1:' . $highestColumn . '1' );
$fieldList = array( "None" );
foreach( $headerList[0] as $fName ) {
$fieldList[] = $fName;
}
$fieldNum = 1;
foreach ( array( "DataCenterID"=>"The exact name of the target data center for import.", "Cabinet"=>"The name (Location) of the target cabinet.", "Position"=>"The position in the cabinet for the device. 0 is valid for zero-U devices. No collision checking is performed.", "Label"=>"The value to place in the Label field.", "Height"=>"The height of the device, 0 is a valid value.", "Manufacturer"=>"The name of the Manufacturer. This is combined with the Model field to create the 'Device Class'.", "Model"=>"The model name, as specified in the existing Device Template, which will be combined with the Manufacturer to choose the 'Device Class'.", "Hostname"=>"An optional IP address or hostname for the device.", "SerialNo"=>"An optional value to place in the Serial Number field of the device.", "AssetTag"=>"An optional Asset or Property number to assign to the device.", "HalfDepth"=>"Optional, specify 1 or Y to indicate this device only occupies half the depth of the cabinet.", "BackSide"=>"Optional, specify 1 or Y to indicate that this device is mounted from the rear of the cabinet.", "Hypervisor"=>"Optional, specify 'ESX', 'ProxMox', or blank (for default behavior of 'None').", "InstallDate"=>"If blank, current date is used, otherwise this mandatory field can contain any ISO valid date format.", "Status"=>"Optional, default will be set to 'Reserved' if not specified. Value must exist as a Device Status in the database.", "Owner"=>"Optional, and may be blank. This is the name of the Department that owns the device.", "PrimaryContact"=>"Optional, and may be blank. The exact name of the Primary Contact for this device in LastName, FirstName format.", "CustomTags"=>"A comma separated list of tags to apply to the device. Tags do not have to already exist within openDCIM." ) as $fieldName=>$helpText ) {
$content .= '<div>
<div><span title="' . __($helpText) . '">' . __($fieldName) . '</span>: </div><div><select name="' . $fieldName . '">';
for ( $n = 0; $n < sizeof( $fieldList ); $n++ ) {
if ( $n == $fieldNum )
$selected = "SELECTED";
else
$selected = "";
$content .= "<option value=$n $selected>$fieldList[$n]</option>\n";
}
$content .= '</select>
</div>
</div>';
$fieldNum++;
}
$content .= "<div><div></div><div><input type='submit' value='" . __("Validate") . "' name='submit'></div></div>";
$content .= '</form>
</div>';
} elseif ( isset($_REQUEST['stage']) && $_REQUEST['stage'] == 'validate' ) {
// Certain fields we are going to require that the values exist in the db already (if a value is specified)
//
// Data Center
// Cabinet
// Manufacturer
// Model
// Owner (Department)
// Primary Contact
//
// Everything else is just meta data
//
// Once again, open the uploaded Excel file. Will possibly move to a function to eliminate repetition.
$targetFile = $_SESSION['inputfile'];
try {
$inFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($targetFile);
$objReader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inFileType);
$objXL = $objReader->load($targetFile);
} catch (Exception $e) {
die("Error opening file: ".$e->getMessage());
}
// Start off assuming we're valid, then set it once we're not
$valid = true;
// Now go through the values in the sheet to validate the required key fields to see if there are any errors before
// we do any actual inserts into the database
$content = "<h3>" . __("The following required fields are not mapped") . ":</h3><ul>";
foreach ( array( "DataCenterID", "Cabinet", "Position", "Label", "Height", "Manufacturer", "Model" ) as $required ) {
if ( ! isset($_REQUEST[$required]) || isset($_REQUEST[$required]) && $_REQUEST[$required] == 0 ) {
$content .= "<li>$required";
$valid = false;
}
}
if ( ! $valid ) {
$content .= "</ul></div>";
} else {
$content = "";
}
// Required keys are defined, now cycle through all of the rows in the spreadsheet to check for valid data
if ( $valid ) {
$values = array();
$fields = array( "DataCenterID", "Cabinet", "Manufacturer", "Model", "Owner", "PrimaryContact" );
// Skip the first row, which has the headers in it
$rowNum = 1;
$sheet = $objXL->getSheet(0);
$highestRow = $sheet->getHighestRow();
$rowNum = 1;
for ( $n = 2; $n <= $highestRow; $n++ ) {
$rowError = false;
// Load up the $row[] array with the values according to the mapping supplied by the user
foreach( $fields as $fname ) {
if ( $_REQUEST[$fname] != 0 ) {
$addr = chr( 64 + $_REQUEST[$fname]);
$row[$fname] = sanitize($sheet->getCell( $addr . $n )->getValue());
} else {
$row[$fname] = "";
}
}
// Stop reading once we get to the first line without a datacenter
if ( trim($row["DataCenterID"]) == "" ) {
break;
}
// Have to do this part by hand because some fields are actually context dependent upon others
$values["DataCenterID"][] = $row["DataCenterID"];
$tmpCab["DataCenterID"] = $row["DataCenterID"];
$tmpCab["Cabinet"] = $row["Cabinet"];
$values["Cabinet"][] = $tmpCab;
$values["Manufacturer"][] = $row["Manufacturer"];
$tmpModel["Manufacturer"] = $row["Manufacturer"];
$tmpModel["Model"] = $row["Model"];
$values["Model"][] = $tmpModel;
if ( $row["Owner"] != "" ) {
$values["Owner"][] = $row["Owner"];
}
if ( $row["PrimaryContact"] != "" ) {
$values["PrimaryContact"][] = $row["PrimaryContact"];
}
}
foreach( $values as $key => $val ) {
$values[$key] = array_unique( $values[$key], SORT_REGULAR );
}
if ( $valid ) {
// This could probably be economized in some fashion, but I can just crank this out faster one at a time and worry about efficiency later
//
$tmpCon = "<h3>" . __("The following values in the import file require entries in openDCIM before you may proceed.") . "</h3>";
$tmpCon .= "<ul>";
$st = $dbh->prepare( "select DataCenterID from fac_DataCenter where ucase(Name)=ucase(:Name)" );
foreach ( $values["DataCenterID"] as $val ) {
$st->execute( array( ":Name" => $val ));
if ( ! $st->fetch()) {
$valid = false;
$tmpCon .= "<li>" . __("Data Center") . ": $val";
}
}
// To check validity of cabinets, we have to know the data center for that specific cabinet.
$st = $dbh->prepare( "select CabinetID from fac_Cabinet where ucase(Location)=ucase( :Location ) and DataCenterID in (select DataCenterID from fac_DataCenter where ucase(Name)=ucase( :DataCenter ))" );
foreach( $values["Cabinet"] as $row ) {
$st->execute( array( ":Location"=>$row["Cabinet"], ":DataCenter"=>$row["DataCenterID"] ));
if ( ! $row = $st->fetch()) {
$valid = false;
$tmpCon .= "<li>" . __("Cabinet") . ": " . $row["DataCenterID"] . " - " . $row["Cabinet"];
}
}
// Check the Manufacturer Names for validity
$st = $dbh->prepare( "select ManufacturerID from fac_Manufacturer where ucase(Name)=ucase(:Name)" );
foreach ( $values["Manufacturer"] as $val ) {
if ( $val != "" ) {
$st->execute( array( ":Name" => $val ) );
if ( ! $st->fetch() ) {
$valid = false;
$tmpCon .= "<li>" . __("Manufacturer") . ": " . $val;
}
}
}
// Check the Model for validity, which is like cabinets - it requires the Manufacturer paired with the Model to check.
$st = $dbh->prepare( "select * from fac_DeviceTemplate where ucase(Model)=ucase(:Model) and ManufacturerID in (select ManufacturerID from fac_Manufacturer where ucase(Name)=ucase(:Manufacturer))" );
foreach( $values["Model"] as $row ) {
$st->execute( array( ":Model"=>$row["Model"], ":Manufacturer"=>$row["Manufacturer"] ));
if ( ! $st->fetch() ) {
$valid = false;
$tmpCon .= "<li>" . __("Model") . ": " . $row["Manufacturer"] . " - " . $row["Model"];
}
}
// Check for the Department to be valid
if ( isset($values["Owner"] )) {
$st = $dbh->prepare( "select DeptID from fac_Department where ucase(Name)=ucase( :Name )" );
foreach( $values["Owner"] as $val ) {
$st->execute( array( ":Name"=>$val ));
if ( ! $st->fetch() ) {
$valid = false;
$tmpCon .= "<li>" . __("Department") . ": " . $val;
}
}
}
// Finally, check on the Primary Contact
if ( isset($values["PrimaryContact"] )) {
$st = $dbh->prepare( "select PersonID from fac_People where ucase(concat(LastName, ', ', FirstName))=ucase(:Contact)" );
foreach( $values["PrimaryContact"] as $val ) {
if ( $val != "" ) {
$st->execute( array( ":Contact" => $val ));
if ( ! $st->fetch()) {
$valid = false;
$tmpCon .= "<li>" . __("Primary Contact") . ":" . $val;
}
}
}
}
// Now quickly run back through all of the rows and check for collisions
$st = $dbh->prepare( "select DeviceID, Label from fac_Device where ParentDevice=0 and Cabinet in (select CabinetID from fac_Cabinet where DataCenterID in (select DataCenterID from fac_DataCenter where ucase(Name)=ucase(:DataCenterID)) and ucase(Location)=ucase(:Cabinet)) and (Position between :StartPos and :EndPos or Position+Height-1 between :StartPos2 and :EndPos2)" );
$cFields = array( "DataCenterID", "Cabinet", "Position", "Height", "Label" );
$sheet = $objXL->getSheet(0);
$highestRow = $sheet->getHighestRow();
$rowNum = 1;
for ( $n = 2; $n <= $highestRow; $n++ ) {
$rowError = false;
// Load up the $row[] array with the values according to the mapping supplied by the user
foreach( $fields as $fname ) {
if ( $_REQUEST[$fname] != 0 ) {
$addr = chr( 64 + $_REQUEST[$fname]);
$row[$fname] = sanitize($sheet->getCell( $addr . $n )->getValue());
} else {
$row[$fname] = "";
}
}
// Stop reading once we get to the first line without a datacenter
if ( trim($row["DataCenterID"]) == "" ) {
break;
}
// Any floating point value refers to a card going into a server. Since the server
// being added could be a row in this field, we simply don't detect collisions
// and will show an error during processing if it comes to that.
$pos = explode( ".", $row["Position"]);
// Floating point entries once split will have 2 or more members in the $pos array
if ( sizeof( $pos ) < 2 ) {
if ( $row["Height"] > 0 ) {
$endPos = $row["Position"] + $row["Height"] - 1;
if ( ! $st->execute( array( ":DataCenterID"=>$row["DataCenterID"],
":Cabinet"=>$row["Cabinet"],
":StartPos"=>$row["Position"],
":EndPos"=>$endPos,
":StartPos2"=>$row["Position"],
":EndPos2"=>$endPos )) ) {
$info = $dbh->errorInfo();
error_log( "PDO Error on Collision Detection: {$info[2]}" );
}
if ( $collisionRow = $st->fetch() ) {
$tmpCon .= "<li>" . __("Collision Detected") . ": " . $row["DataCenterID"] . ":" . $row["Cabinet"] . " - " . $row["Position"] . " :: " . $row["Label"];
$valid = false;
}
}
}
}
if ( ! $valid ) {
$content .= $tmpCon . "</ul>";
} else {
$content = '<form method="POST">';
$content .= "<h3>" . __( "The file has passed validation. Press the Process button to import." ) . "</h3>";
$content .= "<input type=\"hidden\" name=\"stage\" value=\"process\">\n";
foreach( array( "DataCenterID", "Cabinet", "Position", "Label", "Height", "Manufacturer", "Model", "Hostname", "SerialNo", "AssetTag", "Hypervisor", "BackSide", "HalfDepth", "Status", "InstallDate", "Owner", "PrimaryContact", "CustomTags" ) as $mapVar ) {
$content .= "<input type=\"hidden\" name=\"" . $mapVar . "\" value=\"" . $_REQUEST[$mapVar] . "\">\n";
}
$content .= '<div>
<input type="submit" value="' . __("Process") . '" name="submit">
</div>
</form>';
}
}
}
} elseif ( isset($_REQUEST['stage']) && $_REQUEST['stage'] == 'process' ) {
// Open the file to finally do some actual inserts this time
$targetFile = $_SESSION['inputfile'];
try {
$inFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($targetFile);
$objReader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inFileType);
$objXL = $objReader->load($targetFile);
} catch (Exception $e) {
die("Error opening file: ".$e->getMessage());
}
// Start off with the assumption that we have zero processing errors
$errors = false;
$trueArray = array( "1", "Y", "YES" );
// Also make sure we start with an empty string to display
$content = "";
$fields = array( "DataCenterID", "Cabinet", "Position", "Label", "Height", "Manufacturer", "Model", "Hostname", "SerialNo", "AssetTag", "Hypervisor", "BackSide", "HalfDepth", "Status", "Owner", "InstallDate", "PrimaryContact", "CustomTags" );
$sheet = $objXL->getSheet(0);
$highestRow = $sheet->getHighestRow();
$rowNum = 1;
for ( $n = 2; $n <= $highestRow; $n++ ) {
$rowError = false;
// Load up the $row[] array with the values according to the mapping supplied by the user
foreach( $fields as $fname ) {
if ( $_REQUEST[$fname] != 0 ) {
$addr = chr( 64 + $_REQUEST[$fname]);
$row[$fname] = sanitize($sheet->getCell( $addr . $n )->getValue());
} else {
$row[$fname] = "";
}
}
// Stop reading once we get to the first line without a datacenter
if ( trim($row["DataCenterID"]) == "" ) {
break;
}
$dev = new Device();
// Now start getting the foreign keys as needed and set them in the $dev variable
$st = $dbh->prepare( "select DataCenterID from fac_DataCenter where ucase(Name)=ucase(:Name)" );
$st->execute( array( ":Name" => $row["DataCenterID"] ));
if ( ! $val = $st->fetch()) {
// We just checked this, so there really shouldn't be an issue unless the db died
$info = $dbh->errorInfo();
error_log( "PDO Error: {$info[2]} (Data Center search)");
}
$dev->DataCenterID = $val["DataCenterID"];
$st = $dbh->prepare( "select CabinetID from fac_Cabinet where ucase(Location)=ucase( :Location ) and DataCenterID=:DataCenterID" );
$st->execute( array( ":Location"=>$row["Cabinet"], ":DataCenterID"=>$dev->DataCenterID ));
if ( ! $val = $st->fetch()) {
$info = $dbh->errorInfo();
error_log( "PDO Error: {$info[2]} (Cabinet search)");
}
$dev->Cabinet = $val["CabinetID"];
$pos = explode( ".", $row["Position"] );
if ( sizeof( $pos ) > 1 ) {
// This is a child (card) so we need to find the parent
$pDev = new Device();
$pDev->Cabinet = $dev->Cabinet;
$pDev->ParentDevice = 0;
$pDev->Position = $pos[0];
$pList = $pDev->Search();
if ( sizeof( $pList ) != 1 ) {
$content .= "<li>" . __("Parent device does not exist at specified location." );
$errors = true;
} else {
$dev->ParentDevice = $pList[0]->DeviceID;
$dev->Position = $pos[1];
}
} else {
$dev->Position = $row["Position"];
}
$dev->Label = $row["Label"];
$dev->Height = $row["Height"];
$st = $dbh->prepare( "select * from fac_DeviceTemplate where ucase(Model)=ucase(:Model) and ManufacturerID in (select ManufacturerID from fac_Manufacturer where ucase(Name)=ucase(:Manufacturer))" );
$st->execute( array( ":Model" => $row["Model"], ":Manufacturer"=>$row["Manufacturer"] ));
if ( ! $val = $st->fetch()) {
$info = $dbh->errorInfo();
error_log( "PDO Error: {$info[2]} (Template search)");
}
$dev->TemplateID = $val["TemplateID"];
$dev->Ports = $val["NumPorts"];
$dev->NominalWatts = $val["Wattage"];
$dev->DeviceType = $val["DeviceType"];
$dev->PowerSupplyCount = $val["PSCount"];
$dev->ChassisSlots = $val["ChassisSlots"];
$dev->RearChassisSlots = $val["RearChassisSlots"];
$dev->Weight = $val["Weight"];
$dev->PrimaryIP = $row["Hostname"];
$dev->SerialNo = $row["SerialNo"];
$dev->AssetTag = $row["AssetTag"];
$dev->BackSide = in_array( strtoupper($row["BackSide"]), $trueArray);
$dev->HalfDepth = in_array( strtoupper($row["HalfDepth"]), $trueArray);
$dev->Hypervisor = (in_array( $row["Hypervisor"], array( "ESX", "ProxMox")))?$row["Hypervisor"]:"None";
if ( $row["InstallDate"] != "" ) {
$dev->InstallDate = date( "Y-m-d", strtotime( $row["InstallDate"]));
} else {
$dev->InstallDate = date( "Y-m-d" );
}
$dev->Status = in_array($row["Status"], DeviceStatus::getStatusNames() )?$row["Status"]:"Reserved";
if ( $row["Owner"] != "" ) {
$st = $dbh->prepare( "select DeptID from fac_Department where ucase(Name)=ucase(:Name)" );
$st->execute( array( ":Name" => $row["Owner"] ));
if ( ! $val = $st->fetch()) {
$info = $dbh->errorInfo();
error_log( "PDO Error: {$info[2]} (Department search)");
}
$dev->Owner = $val["DeptID"];
}
if ( $row["PrimaryContact"] != "" ) {
$st = $dbh->prepare( "select PersonID from fac_People where ucase(concat(LastName, ', ', FirstName))=ucase(:Contact)" );
$st->execute( array( ":Contact" => $row["PrimaryContact"] ));
if ( ! $val = $st->fetch()) {
$info = $dbh->errorInfo();
error_log( "PDO Error: {$info[2]} (Primary Contact search)");
}
$dev->PrimaryContact = $val["PersonID"];
}
if ( ! $errors && ! $dev->CreateDevice() ) {
$errors = true;
$content .= "<li><strong>" . __("Error adding device on Row $n of the spreadsheet.") . "</strong>";
} else {
if ( $row["CustomTags"] != "" ) {
$tagList = array_map( 'trim', explode( ",", $row["CustomTags"] ));
$dev->SetTags( $tagList );
}
$content .= "<li>Added device " . $dev->Label . "(" . $dev->DeviceID . ")";
}
}
if ( ! $errors ) {
$content = __("All records imported successfully.") . "<ul>" . $content . "</ul>";
} else {
$content = __("At least one error was encountered processing the file. Please see below.") . "<ul>" . $content . "</ul>";
}
} else {
//
// No parameters were passed with the URL, so this is the top level, where
// we need to ask for the user to specify a file to upload.
//
$content = '<form method="POST" ENCTYPE="multipart/form-data">';
$content .= '<div class="table">
<div>
<div>' . __("Select file to upload:") . '
<input type="file" name="inputfile" id="inputfile">
</div>
</div>
<div>
<div>
<input type="submit" value="Upload" name="submit">
</div>
</div>
</div>
</form>
</div>';
}
//
// Render the page with the main section being whatever has been loaded into the
// variable $content - every stage spills out to here other than the file upload
//
?>
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>openDCIM</title>
<link rel="stylesheet" href="css/inventory.php" type="text/css">
<link rel="stylesheet" href="css/jquery-ui.css" type="text/css">
<!--[if lt IE 9]>
<link rel="stylesheet" href="css/ie.css" type="text/css" />
<![endif]-->
<script type="text/javascript" src="scripts/jquery.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui.min.js"></script>
</head>
<body>
<?php include( 'header.inc.php' ); ?>
<div class="page index">
<?php
include( 'sidebar.inc.php' );
?>
<div class="main">
<div class="center"><div>
<?php
echo $content;
?>
<!-- CONTENT GOES HERE -->
</div></div>
</div><!-- END div.main -->
</div><!-- END div.page -->
</body>
</html>