function showUsers($con) { // Select all the rows in the markers table $query = "SELECT \n" . " * \n" . "FROM \n" . " users u \n" . " left join user_types ut on u.user_type_id = ut.user_type_id \n" . "ORDER BY \n" . " u.user_id;"; $result = mysqli_query($con, $query); if (!$result) { die('Invalid query: ' . mysql_error()); } echo "<table border='1' style='width:100%' class='table'>\n"; echo "<thead><tr>\n"; echo "<th>id</th>\n"; echo "<th>name</th>\n"; echo "<th>type</th>\n"; echo "<th>reset pass</th>\n"; echo "<th>delete</th>\n"; echo "</tr></thead>\n"; echo "<tbody>\n"; while ($row = @mysqli_fetch_assoc($result)) { $typeSQL = "SELECT user_type_id, user_type_name from user_types order by user_type_id"; $typesDropDown = buildDropDown($con, $typeSQL, $row['user_type_id'], "type", "users", "user_type_id", "user_type_name", "user_id", $row['user_id'], false); echo "<td>" . $row['user_id'] . "</td>\n"; echo getTableRow($row, "user_name", "users", "user_id", "", ""); echo "<td>" . $typesDropDown . "</td>\n"; echo "<td><a onclick='newPass(" . $row['user_id'] . ")' href='javascript:void(0);'>reset pass</a></td>\n"; echo "<td><a onclick='deleteRecord(\"users\", \"user_id=" . $row['user_id'] . "\", true)' href='javascript:void(0);'>[X]</a></td>\n"; echo "</tr>\n"; } echo "</tbody>\n"; echo "</table>\n"; }
function showDevices($con) { // Select all the rows in the markers table $query = "SELECT \n" . " gd.*, \n" . " gowner.gps_owner_name as gps_owner_name \n" . "FROM \n" . " gps_device gd \n" . " left join gps_owner gowner on gd.gps_device_id = gowner.gps_owner_id \n" . "ORDER BY \n" . " gd.gps_device_id;"; $result = mysqli_query($con, $query); if (!$result) { die('Invalid query: ' . mysql_error()); } echo "<table border='1' style='width:100%' class='table'>\n"; echo "<thead><tr>\n"; echo "<th>id</th>\n"; echo "<th>device id</th>\n"; echo "<th>name</th>\n"; echo "<th>desc</th>\n"; echo "<th>comment</th>\n"; echo "<th>owner</th>\n"; echo "<th>delete</th>\n"; echo "</tr></thead>\n"; echo "<tbody>\n"; while ($row = @mysqli_fetch_assoc($result)) { $ownersSQL = "SELECT gps_owner_id, gps_owner_name from gps_owner \n" . "order by gps_owner_id"; $ownersDropDown = buildDropDown($con, $ownersSQL, $row['gps_owner_id'], "owner", "gps_device", "gps_owner_id", "gps_owner_name", "gps_device_id", $row['gps_device_id'], true); echo "<td>" . $row['gps_device_id'] . "</td>\n"; echo getTableRow($row, "gps_device_local_id", "gps_device", "gps_device_id", "", ""); echo getTableRow($row, "gps_device_name", "gps_device", "gps_device_id", "", ""); echo getTableRow($row, "gps_device_desc", "gps_device", "gps_device_id", "", ""); echo getTableRow($row, "gps_device_comment", "gps_device", "gps_device_id", "", ""); echo "<td>" . $ownersDropDown . "</td>\n"; echo "<td><a onclick='updateDelete(\"gps_entries\", \"gps_device_id\", \"NULL\", \"gps_device\", \"gps_device_id=" . $row['gps_device_id'] . "\", true)' href='javascript:void(0);'>[X]</a></td>\n"; echo "</tr>\n"; } echo "</tbody>\n"; echo "</table>\n"; }
function showMarkers($con, $sort = "") { // Select all the rows in the markers table $query = "SELECT \n" . " ge.*, \n" . " gp.gps_path_name as gps_path_name, \n" . " gt.gps_type_name as gps_type_name \n" . "FROM \n" . " gps_entries ge \n" . " left join gps_path gp on ge.gps_path_id = gp.gps_path_id \n" . " left join gps_type gt on ge.gps_type_id = gt.gps_type_id \n" . "ORDER BY \n" . $sort . " ge.gps_date, ge.gps_entry_id;"; $result = mysqli_query($con, $query); if (!$result) { die('Invalid query: ' . mysql_error()); } echo "<table border='1' style='width:100%' class='table'>\n"; echo "<thead><tr>\n"; //echo "<td>hide</td>\n"; echo "<th>id</th>\n"; echo "<th>date</th>\n"; echo "<th>name</th>\n"; echo "<th>address</th>\n"; echo "<th>lat</th>\n"; echo "<th>long</th>\n"; echo "<th>status</th>\n"; echo "<th>path</th>\n"; echo "<th>type</th>\n"; echo "<th>device</th>\n"; echo "<th>delete</th>\n"; echo "</thead></tr>\n"; echo "<tbody>\n"; //TODO Add marker path sequence values while ($row = @mysqli_fetch_assoc($result)) { $pathSQL = "SELECT gps_path_id, gps_path_name from gps_path \n" . "where (gps_path_status <> 'H' OR gps_path_status is null) \n" . "order by gps_path_id"; $pathsDropDown = buildDropDown($con, $pathSQL, $row['gps_path_id'], "path", "gps_entries", "gps_path_id", "gps_path_name", "gps_entry_id", $row['gps_entry_id'], true); //load types drop down $typesSQL = "SELECT gps_type_id, gps_type_name \n" . "from gps_type \n" . "order by gps_type_id"; $typesDropDown = buildDropDown($con, $typesSQL, $row['gps_type_id'], "type", "gps_entries", "gps_type_id", "gps_type_name", "gps_entry_id", $row['gps_entry_id'], true); //load device drop down $deviceSQL = "SELECT gps_device_id, gps_device_name from gps_device \n" . "order by gps_device_id"; $deviceDropDown = buildDropDown($con, $deviceSQL, $row['gps_device_id'], "device", "gps_entries", "gps_device_id", "gps_device_name", "gps_entry_id", $row['gps_entry_id'], true); echo "<td><a href='view.php?marker_id=" . $row['gps_entry_id'] . "&zoom=15¢er=" . $row['gps_latitude'] . "," . $row['gps_longitude'] . "&edit=true'>" . $row['gps_entry_id'] . "</a></td>\n"; echo getTableRow($row, "gps_date", "gps_entries", "gps_entry_id", "", ""); echo getTableRow($row, "gps_name", "gps_entries", "gps_entry_id", "", ""); echo getTableRow($row, "gps_address1", "gps_entries", "gps_entry_id", "", ""); echo getTableRow($row, "gps_latitude", "gps_entries", "gps_entry_id", "", ""); echo getTableRow($row, "gps_longitude", "gps_entries", "gps_entry_id", "", ""); echo "<td>\n" . buildSetStatusDropDown($row['gps_status'], $row['gps_entry_id']) . "</td>\n"; echo "<td>" . $pathsDropDown . "</td>\n"; echo "<td>" . $typesDropDown . "</td>\n"; echo "<td>" . $deviceDropDown . "</td>\n"; echo "<td><a onclick='deleteRecord(\"gps_entries\", \"gps_entry_id=" . $row['gps_entry_id'] . "\", true)' href='javascript:void(0);'>[X]</a></td>\n"; echo "</tr>\n"; } echo "</tbody>\n"; echo "</table>\n"; }