function installedStuffLookup($title, $tableName)
{
    ?>
					<section>
						<header class="tableRow gray"><h3><?php 
    echo $title;
    ?>
</h3></header>
<?php 
    global $computer;
    $table = new Table($tableName);
    $result = $table->runQuery();
    $installedItems = explode(" - ", $computer[$table->getName() . "_list"]);
    $i = 0;
    foreach ($result as $row) {
        if ($i == 0) {
            echo "\t\t\t\t<div class=\"tableRow\">";
        }
        $isInstalled = in_array($row[$table->getName() . "_name"], $installedItems);
        echo "\t\t\t\t\t\t\t<div class=\"tableCell quarterWidth" . ($isInstalled ? " gray" : "") . "\">\r\n\t\t\t\t\t\t\t\t<label class=\"configLabel\"><input class=\"configCheckbox\" name=\"{$table->getName()}_list[]\" type=\"checkbox\" value=\"{$row[$table->getName() . "_name"]}\"" . ($isInstalled ? " checked" : "") . "/>\r\n\t\t\t\t\t\t\t\t{$row[$table->getName() . "_name"]}</label>\r\n\t\t\t\t\t\t\t</div>\r\n";
        if ($i++ == 3) {
            echo "\t\t\t\t</div>";
            $i = 0;
        }
    }
    ?>
					</section>
<?php 
}
function echoRow($label1, $fieldName1, $attr1, $label2, $fieldName2, $attr2)
{
    global $computer;
    echo "<div class=\"tableRow\">";
    for ($i = 0; $i < 2; $i++) {
        $label = $i == 0 ? $label1 : $label2;
        $fieldName = $i == 0 ? $fieldName1 : $fieldName2;
        $attr = $i == 0 ? $attr1 : $attr2;
        echo "\n\t\t\t\t\t<div class=\"tableCell quarterWidth\"><label for=\"{$fieldName}\">{$label}:</label></div>\n\t\t\t\t\t<div class=\"tableCell quarterWidth\">\n\t\t\t\t\t\t";
        if ($fieldName === "rebuilder") {
            echo "<select id=\"{$fieldName}Input\" name=\"{$fieldName}\">";
            echo "<option disabled>Select a {$fieldName}</option>";
            $table = new Table($fieldName);
            $table->echoRowsAsOptions($table->runQuery(), $computer[$fieldName]);
            echo "</select>";
            echo "<span class=\"selectPrintValue\">{$computer[$fieldName]}</span>";
        } else {
            echo "<input" . (is_null($attr) ? "" : " " . $attr) . " name=\"{$fieldName}\" type=\"text\" value=\"{$computer[$fieldName]}\"/>";
        }
        echo "\n\t\t\t\t</div>";
    }
    echo "\n\t\t\t</div>\n\t\t\t";
}
<?php

require "checkLoggedInAction.php";
require_once "../mysql/Table.php";
$table = new Table("computer");
if (!isset($_GET["search"])) {
    $computers = $table->runQuery();
} else {
    $computers = $table->runQuery($_GET["search"]);
}
header("Content-Type: text/csv; charset=utf-8");
header("Content-Disposition: attachment; filename=PC-Rebuild-Database-" . (isset($_GET["search"]) ? "[" . str_replace(" ", "", $_GET["search"]) . "]-" : "") . date("m-d-Y") . ".csv");
$output = fopen("php://output", "w");
fputcsv($output, $table->getColumnNames());
foreach ($computers as $computer) {
    fputcsv($output, $computer);
}
Example #4
0
				<div class="tableRow">
					<h3><a href="addComputer.php"><span class="green">Add</span> a new computer</a></h3>
					Click on this box to create a new rebuild form or to just enter a new machine into the database.
				</div>
				<div class="tableRow">
					<h3><a href="addOrDeleteItems.php"><span class="green">Add</span> or <span class="red">delete</span> items from the database</a></h3>
					Click here to add or delete applications, printers, updates, configurations, hardware, and operating systems.
				</div>
				<div class="tableRow">
					<h3><span class="blue">View</span> a computer</h3>
					Edit and create a printable report of any computer:
					<select id="computerName" name="computerName">
						<option disabled>Select a computer</option>
						<?php 
$table = new Table("computer");
$table->echoRowsAsOptions($table->runQuery());
echo "\n";
?>
					</select>
				</div>
				<div class="tableRow">
					<h3><a href="viewDatabase.php"><span class="blue">View</span> the database</a></h3>
					View and search the entire computer database, sorted by computer name.
				</div>
			</section>
		</main>
		<?php 
include "templates/footer.php";
?>
	</body>
</html>
function echoAddOrDeleteBox($tableName, $title, $buttonText)
{
    ?>
<div class="tableRow">
							<div class="tableCell halfWidth">
								<h3><span class="green">Add</span> <?php 
    echo $title;
    ?>
</h3>
								<form>
									<input id="item" name="item" type="text"/>
									<button class="addButton">Add <?php 
    echo $buttonText;
    ?>
</button>
									<input type="hidden" name="tableName" value="<?php 
    echo $tableName;
    ?>
"/>
								</form>
							</div>
							<div class="tableCell halfWidth">
								<h3><span class="red">Delete</span> <?php 
    echo $title;
    ?>
</h3>
								<form>
									<select class="deleteSelect" name="item">
										<?php 
    $table = new Table($tableName);
    $table->echoRowsAsOptions($table->runQuery());
    echo "\n";
    ?>
									</select>
									<button class="deleteButton">Delete <?php 
    echo $buttonText;
    ?>
</button>
									<input name="tableName" type="hidden" value="<?php 
    echo $tableName;
    ?>
"/>
								</form>
							</div>
						</div><?php 
}