<?php

include("postget.php");
include_once("common.php");
$pagetitle = _USERS;

checklevel(4, $_REQUEST['clientid']);
if ($config[56][1] == 1) {
    messagetop(_CHANGE_NOT_ALLOWED_IN_DEMO_MODE, '', 'main.php', 0);
}
//$query = "SELECT count(name) FROM hd_users";
//$result = mysql_query($query, $db_link);
//$one = mysql_fetch_row($result);
//if($one[0]==0){$_SESSION['hd_accesslvl']=9;}
$query = "SELECT * FROM hd_users ORDER BY access DESC, name ASC";
$result = mysql_query($query, $db_link);
include("head_template.php");
echo '
<div class="container">
	<div class="row">
';

echo '<table class="table table-striped">';

print("<thead><tr>
	<th>" . _USERS . "</th> 
 	<th>" . _LEVEL . "</th> 	
	<th>" . _DEPARTMENT . "</th> 
	<th>" . _OPTIONS . "</th> 
	</tr></thead><tbody>");

while ($row = mysql_fetch_array($result)) {
    print("<tr><td>".$row['name']."</td>");
    print("<td align=center>");
    if ($row['access'] == '2') {
        print(lang('_STAFF'));
    }
    if ($row['access'] == '4') {
        print(lang('_ADMINISTRATOR'));
    }
    print("</td>");
    print("<td>");
    if ($row['depid'] == 0) {
        print(lang('_ALL'));
    } else {
        $userdept = query("SELECT name FROM hd_tickets_dep WHERE depid=" . $row['depid'], 1);
        print($userdept['name']);
    }
    print("</td>");

    print("<td align=center>" . btnedit("users2.php?name=$row[name]") . "");
    print("" . btndelete("users3.php?name=$row[name]") . "</td></tr>");
}
print("</tbody></table>");

graybutton("users2.php", _ADD_USER);

echo '
</div>
</div>
';

include("foot_template.php");
?>
	
