Split info page into two columns

This commit is contained in:
Skylar Ittner 2018-06-27 02:04:31 -06:00
parent a00d6c78d2
commit 6782d518eb

View File

@ -8,120 +8,128 @@
</h5> </h5>
</div> </div>
<div class="card-body"> <div class="card-body">
<?php <div class="row">
require_once __DIR__ . "/../machine.php"; <?php
require_once __DIR__ . "/../machine.php";
try { try {
$machine = new Machine($_GET['serial']); $machine = new Machine($_GET['serial']);
$info = $machine->getMachineInfo(); $info = $machine->getMachineInfo();
if (count($info) > 0) { if (count($info) > 0) {
?>
<h6>Machine Info:</h6>
<div class="list-group">
<?php
foreach ($info as $key => $val) {
if (empty($val)) {
continue;
}
$echo = "";
switch ($key) {
case "model":
$echo = "Model: " . htmlspecialchars($val);
break;
case "condition":
$filled = floor($val);
$echo = "Condition: ";
$empty = 10;
while ($filled > 0) {
$filled--;
$empty--;
$echo .= "<i class=\"fas fa-star\"></i> ";
}
if ($val - floor($val) > 0.75) {
$empty--;
$echo .= "<i class=\"fas fa-star\"></i> ";
} else if ($val - floor($val) > 0.25) {
$empty--;
$echo .= "<i class=\"fas fa-star-half-alt\"></i> ";
}
while ($empty > 0) {
$empty--;
$echo .= "<i class=\"far fa-star\"></i> ";
}
break;
case "price":
$echo = "Sale Value: $" . number_format($val * 1.0, 2);
break;
case "notes":
$echo = "<div>" . htmlspecialchars($val) . "</div>";
break;
}
if ($echo != "") {
echo "<div class=\"list-group-item\">\n$echo\n</div>\n";
}
}
?> ?>
</div> <div class="col-sm-6 mb-3">
<?php <h6>Machine Info:</h6>
} <div class="list-group">
<?php
foreach ($info as $key => $val) {
$history = $machine->getHistory(); if (empty($val)) {
continue;
if (count($history) > 0) { }
?> $echo = "";
<h6 class="mt-3">History:</h6> switch ($key) {
<div class="list-group"> case "model":
$echo = "Model: " . htmlspecialchars($val);
break;
case "condition":
$filled = floor($val);
$echo = "Condition: ";
$empty = 10;
while ($filled > 0) {
$filled--;
$empty--;
$echo .= "<i class=\"fas fa-star\"></i> ";
}
if ($val - floor($val) > 0.75) {
$empty--;
$echo .= "<i class=\"fas fa-star\"></i> ";
} else if ($val - floor($val) > 0.25) {
$empty--;
$echo .= "<i class=\"fas fa-star-half-alt\"></i> ";
}
while ($empty > 0) {
$empty--;
$echo .= "<i class=\"far fa-star\"></i> ";
}
break;
case "price":
$echo = "Sale Value: $" . number_format($val * 1.0, 2);
break;
case "notes":
$echo = "<div>" . htmlspecialchars($val) . "</div>";
break;
}
if ($echo != "") {
echo "<div class=\"list-group-item\">\n$echo\n</div>\n";
}
}
?>
</div>
</div>
<?php <?php
foreach ($history as $h) { }
echo "<div class=\"list-group-item\">\n";
echo "<b>$h[eventname]</b> on " . date(DATETIME_FORMAT, strtotime($h['date'])) . "<br />\n";
if (!empty($h['notes'])) { $components = $machine->getComponents();
echo "<div>" . htmlspecialchars($h['notes']) . "</div>";
} if (count($components) > 0) {
echo "\n</div>\n";
}
?> ?>
</div> <div class="col-sm-6 mb-3">
<?php <h6>Components:</h6>
} <div class="list-group">
<?php
foreach ($components as $c) {
$components = $machine->getComponents(); echo "<div class=\"list-group-item\">\n";
echo "<b>$c[type]</b><br />\n";
if (count($components) > 0) { echo "Serial: $c[serial]<br />\n";
?> if (!empty($c['tested'])) {
<h6 class="mt-3">Components:</h6> echo "Tested on: " . date(DATETIME_FORMAT, strtotime($c['tested'])) . "<br />\n";
<div class="list-group"> }
if (!empty($c['capacity'])) {
echo "Capacity: $c[capacity]<br />\n";
}
if (!empty($c['model'])) {
echo "Model: $c[model]<br />\n";
}
if (!empty($h['notes'])) {
echo "<div>" . htmlspecialchars($h['notes']) . "</div>";
}
echo "\n</div>\n";
}
?>
</div>
</div>
<?php <?php
foreach ($components as $c) { }
echo "<div class=\"list-group-item\">\n";
echo "<b>$c[type]</b><br />\n";
echo "Serial: $c[serial]<br />\n"; $history = $machine->getHistory();
if (!empty($c['tested'])) {
echo "Tested on: " . date(DATETIME_FORMAT, strtotime($c['tested'])) . "<br />\n"; if (count($history) > 0) {
}
if (!empty($c['capacity'])) {
echo "Capacity: $c[capacity]<br />\n";
}
if (!empty($c['model'])) {
echo "Model: $c[model]<br />\n";
}
if (!empty($h['notes'])) {
echo "<div>" . htmlspecialchars($h['notes']) . "</div>";
}
echo "\n</div>\n";
}
?> ?>
</div> <div class="col-sm-6 mb-3">
<?php <h6>History:</h6>
<div class="list-group">
<?php
foreach ($history as $h) {
echo "<div class=\"list-group-item\">\n";
echo "<b>$h[eventname]</b> on " . date(DATETIME_FORMAT, strtotime($h['date'])) . "<br />\n";
if (!empty($h['notes'])) {
echo "<div>" . htmlspecialchars($h['notes']) . "</div>";
}
echo "\n</div>\n";
}
?>
</div>
</div>
<?php
}
} catch (Exception $ex) {
echo "<p class=\"text-danger\">" . $ex->getMessage() . "</p>";
} }
} catch (Exception $ex) { ?>
echo "<p class=\"text-danger\">" . $ex->getMessage() . "</p>"; </div>
}
?>
</div> </div>
<div class="card-body"> <div class="card-body">
<p>Look up another machine:</p> <p>Look up another machine:</p>