Split info page into two columns

master
Skylar Ittner 6 years ago
parent a00d6c78d2
commit 6782d518eb

@ -8,120 +8,128 @@
</h5>
</div>
<div class="card-body">
<?php
require_once __DIR__ . "/../machine.php";
<div class="row">
<?php
require_once __DIR__ . "/../machine.php";
try {
$machine = new Machine($_GET['serial']);
try {
$machine = new Machine($_GET['serial']);
$info = $machine->getMachineInfo();
$info = $machine->getMachineInfo();
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 (count($info) > 0) {
?>
<div class="col-sm-6 mb-3">
<h6>Machine Info:</h6>
<div class="list-group">
<?php
foreach ($info as $key => $val) {
if (empty($val)) {
continue;
}
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> ";
$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;
}
while ($empty > 0) {
$empty--;
$echo .= "<i class=\"far fa-star\"></i> ";
if ($echo != "") {
echo "<div class=\"list-group-item\">\n$echo\n</div>\n";
}
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>
<?php
}
}
?>
</div>
</div>
<?php
}
$history = $machine->getHistory();
$components = $machine->getComponents();
if (count($history) > 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";
}
if (count($components) > 0) {
?>
</div>
<?php
}
<div class="col-sm-6 mb-3">
<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) {
?>
<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";
}
if (count($history) > 0) {
?>
</div>
<?php
<div class="col-sm-6 mb-3">
<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 class="card-body">
<p>Look up another machine:</p>

Loading…
Cancel
Save