public function render_grid($full_access=false) {
$row_class = "";
$object_array = self::find_all();
$sql = "SELECT DISTINCT name FROM " . self::$table_name . " ORDER BY name ASC";
$name_array = self::find_by_sql($sql);
$sql = "SELECT DISTINCT department FROM " . self::$table_name . " ORDER BY department ASC";
$department_array = self::find_by_sql($sql);
$sql = "SELECT DISTINCT country FROM " . self::$table_name . " ORDER BY country ASC";
$country_array = self::find_by_sql($sql);
$output = "<table class=\"data table-autosort table-autofilter table-autopage:15 table-stripeclass:alternate table-page-number:t1page table-page-count:t1pages table-filtered-rowcount:t1filtercount table-rowcount:t1allcount\" id=\"t1\">";
$output .= "<thead>";
$output .= "<tr>";
$output .= "<th title=\"Click to sort\" class=\"table-filterable table-sortable:default table-sortable\">Name<br />";
$output .= "<select class=\"table-autofilter\" onclick=\"Table.cancelBubble(event)\" onchange=\"Table.filter(this,this)\">";
$output .= "<option value=\"\">Filter: All</option>";
// foreach ($name_array as $name) {
// $output .= "<option value=\"{$name->name}\">{$name->name}</option>";
// }
$output .= "</select>";
$output .= "</th>";
$output .= "<th title=\"Click to sort\" class=\"table-filterable table-sortable:default table-sortable\">Department<br />";
$output .= "<select class=\"table-autofilter\" onclick=\"Table.cancelBubble(event)\" onchange=\"Table.filter(this,this)\">";
$output .= "<option value=\"\">Filter: All</option>";
// foreach ($department_array as $department) {
// $output .= "<option value=\"{$department->department}\">{$department->department}</option>";
// }
$output .= "</select>";
$output .= "</th>";
$output .= "<th title=\"Click to sort\" class=\"table-filterable table-sortable:default table-sortable\">Country<br />";
$output .= "<select class=\"table-autofilter\" onclick=\"Table.cancelBubble(event)\" onchange=\"Table.filter(this,this)\">";
$output .= "<option value=\"\">Filter: All</option>";
// foreach ($country_array as $country) {
// $output .= "<option value=\"{$country->country}\">{$country->country}</option>";
// }
$output .= "</select>";
$output .= "</th>";
$output .= "</tr>";
$output .= "</thead>";
$output .= "<tbody>";
if ($full_access) {
foreach ($object_array as $object) {
$output .= "<tr class=\"{$row_class}\">";
$output .= "<td><a href=\"division_edit.php?id={$object->id}\">{$object->name}</a></td>";
$output .= "<td>{$object->department}</td>";
$output .= "<td>{$object->country}</td>";
$output .= "</tr>";
if ($row_class == "") {
$row_class = "alternate";
} else {
$row_class = "";
}
}
} else {
foreach ($object_array as $object) {
$output .= "<tr class=\"{$row_class}\">";
$output .= "<td>{$object->name}</td>";
$output .= "<td>{$object->department}</td>";
$output .= "<td>{$object->country}</td>";
$output .= "</tr>";
if ($row_class == "") {
$row_class = "alternate";
} else {
$row_class = "";
}
}
}
$output .= "</tbody>";
$output .= "<tfoot>";
$output .= "<tr>";
$output .= "<td class=\"table-page:previous\" style=\"cursor:pointer;\">< < Previous</td>";
$output .= "<td style=\"text-align:center;\">Page <span id=\"t1page\"></span> of <span id=\"t1pages\"></span></td>";
$output .= "<td class=\"table-page:next\" style=\"cursor:pointer;\">Next > ></td>";
$output .= "</tr>";
$output .= "<tr>";
$output .= "<td colspan=\"3\"><span id=\"t1filtercount\"></span> of <span id=\"t1allcount\"></span> rows match filter(s)</td>";
$output .= "</tfoot>";
$output .= "</table>";
return $output;
}