Example #1
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 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";
}
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 
}