Split info page into two columns

master
Skylar Ittner 6 years ago
parent a00d6c78d2
commit 6782d518eb

@ -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="col-sm-6 mb-3">
<div class="list-group"> <h6>Machine Info:</h6>
<?php <div class="list-group">
foreach ($info as $key => $val) { <?php
if (empty($val)) { foreach ($info as $key => $val) {
continue; 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) { $echo = "";
$empty--; switch ($key) {
$echo .= "<i class=\"fas fa-star\"></i> "; case "model":
} else if ($val - floor($val) > 0.25) { $echo = "Model: " . htmlspecialchars($val);
$empty--; break;
$echo .= "<i class=\"fas fa-star-half-alt\"></i> "; 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;
} }
while ($empty > 0) { if ($echo != "") {
$empty--; echo "<div class=\"list-group-item\">\n$echo\n</div>\n";
$echo .= "<i class=\"far fa-star\"></i> ";
} }
break; }
case "price": ?>
$echo = "Sale Value: $" . number_format($val * 1.0, 2); </div>
break; </div>
case "notes": <?php
$echo = "<div>" . htmlspecialchars($val) . "</div>"; }
break;
}
if ($echo != "") {
echo "<div class=\"list-group-item\">\n$echo\n</div>\n";
}
}
?>
</div>
<?php
}
$history = $machine->getHistory(); $components = $machine->getComponents();
if (count($history) > 0) { if (count($components) > 0) {
?>
<h6 class="mt-3">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 class="col-sm-6 mb-3">
<?php <h6>Components:</h6>
} <div class="list-group">
<?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";
if (!empty($c['tested'])) {
echo "Tested on: " . date(DATETIME_FORMAT, strtotime($c['tested'])) . "<br />\n";
}
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
}
$components = $machine->getComponents(); $history = $machine->getHistory();
if (count($components) > 0) { if (count($history) > 0) {
?>
<h6 class="mt-3">Components:</h6>
<div class="list-group">
<?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";
if (!empty($c['tested'])) {
echo "Tested on: " . date(DATETIME_FORMAT, strtotime($c['tested'])) . "<br />\n";
}
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>

Loading…
Cancel
Save