public function displayProfile($user)
 {
     echo "    <h1>" . escape_output($this->name) . ($user->isAdmin() && $this->id == $user->facility['id'] ? "<small><a href='facility.php?action=edit&id=" . intval($this->id) . "'>(edit)</a></small>" : "") . "</h1>\r\n    <h3>People</h3>\r\n    <table class='table table-striped table-bordered dataTable'>\r\n      <thead>\r\n        <tr>\r\n          <th>Name</th>\r\n          <th>Email</th>\r\n          <th>Role</th>\r\n          <th>QA Entries</th>\r\n        </tr>\r\n      </thead>\r\n      <tbody>\n";
     foreach ($this->users as $thisUser) {
         $thisUser = new User($this->dbConn, $thisUser['id']);
         echo "        <tr>\r\n          <td><a href='user.php?action=show&id=" . intval($thisUser->id) . "'>" . escape_output($thisUser->name) . "</a></td>\r\n          <td>" . escape_output($thisUser->email) . "</td>\r\n          <td>" . escape_output(convert_usermask_to_text($thisUser->usermask)) . "</td>\r\n          <td>" . escape_output(count($thisUser->formEntries)) . "</td>\r\n        </tr>\n";
     }
     echo "      </tbody>\r\n    </table>\n";
     echo "    <h3>Machines</h3>\r\n    <table class='table table-striped table-bordered dataTable'>\r\n      <thead>\r\n        <tr>\r\n          <th>Name</th>\r\n          <th>Type</th>\r\n          <th>QA Entries</th>\r\n          <th>Last Entry</th>\r\n        </tr>\r\n      </thead>\r\n      <tbody>\n";
     foreach ($this->machines as $machine) {
         $machine = new Machine($this->dbConn, $machine['id']);
         $lastEntry = new FormEntry($machine->dbConn, count($machine->formEntries) > 0 ? $machine->formEntries[0]['id'] : 0);
         echo "      <tr>\r\n        <td><a href='machine.php?action=show&id=" . intval($machine->id) . "'>" . escape_output($machine->name) . "</a></td>\r\n        <td>" . escape_output($machine->machineType['name']) . "</td>\r\n        <td>" . escape_output(count($machine->formEntries)) . "</td>\r\n        <td>" . escape_output($lastEntry->updatedAt == '' ? "N/A" : format_mysql_timestamp($lastEntry->updatedAt)) . "</td>\r\n      </tr>\n";
     }
     echo "      </tbody>\r\n    </table>\n";
 }
function display_user_profile($user, $user_id)
{
    $userObject = new User($user->dbConn, $user_id);
    echo "<dl class='dl-horizontal'>\r\n    <dt>Email</dt>\r\n    <dd>" . escape_output($userObject->email) . "</dd>\r\n    <dt>Facility</dt>\r\n    <dd><a href='facility.php?action=show&id=" . intval($userObject->facility['id']) . "'>" . escape_output($userObject->facility['name']) . "</a></dd>\r\n    <dt>User Role</dt>\r\n    <dd>" . escape_output(convert_usermask_to_text($userObject->usermask)) . "</dd>\r\n  </dl>\n";
    if ($userObject->isPhysicist()) {
        $form_approvals = $user->dbConn->stdQuery("SELECT `form_entries`.`id`, `qa_month`, `qa_year`, `machine_id`, `machines`.`name` AS `machine_name`, `user_id`, `users`.`name` AS `user_name`, `approved_on` FROM `form_entries` LEFT OUTER JOIN `machines` ON `machines`.`id` = `form_entries`.`machine_id` LEFT OUTER JOIN `users` ON `users`.`id` = `form_entries`.`user_id` WHERE `approved_user_id` = " . intval($userObject->id) . " ORDER BY `approved_on` DESC");
        echo "  <h3>Approvals</h3>\r\n  <table class='table table-striped table-bordered dataTable'>\r\n    <thead>\r\n      <tr>\r\n        <th>QA Date</th>\r\n        <th>Machine</th>\r\n        <th>Submitter</th>\r\n        <th>Approval Date</th>\r\n      </tr>\r\n    </thead>\r\n    <tbody>\n";
        foreach ($userObject->approvals as $approval) {
            echo "      <tr>\r\n        <td><a href='form_entry.php?action=edit&id=" . intval($approval->id) . "'>" . escape_output($approval->qaYear . "/" . $approval->qaMonth) . "</a></td>\r\n        <td><a href='machine.php?action=show&id=" . intval($approval->machine['id']) . "'>" . escape_output($approval->machine['name']) . "</a></td>\r\n        <td><a href='user.php?action=show&id=" . intval($approval->user['id']) . "'>" . escape_output($approval->user['name']) . "</a></td>\r\n        <td>" . escape_output(format_mysql_timestamp($approval->approvedOn)) . "</td>\r\n      </tr>\n";
        }
        echo "    </tbody>\r\n  </table>\n";
    }
    echo "  <h3>Form Entries</h3>\r\n  <table class='table table-striped table-bordered dataTable'>\r\n    <thead>\r\n      <tr>\r\n        <th>Form</th>\r\n        <th>Machine</th>\r\n        <th>Comments</th>\r\n        <th>QA Date</th>\r\n        <th>Submitted on</th>\r\n        <th></th>\r\n      </tr>\r\n    </thead>\r\n    <tbody>\n";
    foreach ($userObject->formEntries as $form_entry) {
        $form_entry = new FormEntry($userObject->dbConn, $form_entry['id']);
        echo "    <tr>\r\n      <td><a href='form.php?action=show&id=" . intval($form_entry->form['id']) . "'>" . escape_output($form_entry->form['name']) . "</a></td>\r\n      <td><a href='machine.php?action=show&id=" . intval($form_entry->machine['id']) . "'>" . escape_output($form_entry->machine['name']) . "</a></td>\r\n      <td>" . escape_output($form_entry->comments) . "</td>\r\n      <td>" . escape_output($form_entry->qaYear . "/" . $form_entry->qaMonth) . "</td>\r\n      <td>" . escape_output(format_mysql_timestamp($form_entry->createdAt)) . "</td>\r\n      <td><a href='form_entry.php?action=edit&id=" . intval($form_entry->id) . "'>View</a></td>\r\n    </tr>\n";
    }
    echo "    </tbody>\r\n  </table>\n";
}