Location: PHPKode > projects > Helpdesk Solutions > helpdesk/scripts/admin/admin_remuser.php
<?
include($DOCUMENT_ROOT.'/helpdesk/include/database.php');
include($DOCUMENT_ROOT.'/helpdesk/include/new_user.php');


session_start();

if ($valid != "yes") {
	header("Location: /helpdesk/login.php");
	exit;
}

$head = "Remove a User";
$bttm_menu = " &nbsp;&nbsp;<a class=bttm_menu href='/helpdesk/scripts/main_adminmenu.php'>Main Menu</a>&nbsp;&nbsp;|
				&nbsp;&nbsp;<a class=bttm_menu href='/helpdesk/scripts/admin/admin_viewuser.php'>View Users</a>&nbsp;&nbsp;|
				&nbsp;&nbsp;<a class=bttm_menu href='/helpdesk/scripts/admin/admin_adduser.php'>Add a User</a>&nbsp;&nbsp;|
				&nbsp;&nbsp;<a class=bttm_menu href='/helpdesk/scripts/admin/admin_moduserview.php'>Modify a User</a>&nbsp;&nbsp;|
				&nbsp;&nbsp;<a class=bttm_menu href='/helpdesk/scripts/admin/admin_remuser.php'>Remove a User</a>&nbsp;&nbsp;|
				&nbsp;&nbsp;<a class=bttm_menu href='/helpdesk/logout.php'>Log Out</a>&nbsp;&nbsp;|
";

//echo "User ID Is: $user_id";
//echo "<br>Main User View: $user_view";
$order_name = "users";

//Checks if the current user has an order already set in dbase.
if (!$submit) {
	if (existorder($conn,$user_id,$order_name)) {
		getorder($conn,$user_id,$order_name); //Sets sessions at same time
		$user_view = $view;
		$user_sorted = $sorted;
		$user_order = $ordering;
	} else {
		//add default values if no values have been set
		$order_name = "users";
		$user_view = "all";
		$user_sorted = 'f_name';
		$user_order = '2';
		addorder($user_id,$order_name,$user_view,$user_sorted,$user_order,$sup_view,$conn); //Sets sessions at same time
	}
}
//Any changes made to the order are added to the dbase here
if ($submit) {
	addorder($user_id,$order_name,$user_view,$user_sorted,$user_order,$sup_view,$conn);  //Sets sessions at same time
	
}

//Drop down Menus
user_getDropMenu('per_id','per_name','user_view','permissions',$conn,$user_view,'yes');
$view_select = $select;

user_getDropMenu('users_dname','users_sortedby','user_sorted','sortedby_users',$conn,$user_sorted,'no');
$sorted_select = $select;

user_getDropMenu('order_id','order_name','user_order','order_order',$conn,$user_order,'no');
$order_select = $select;

//Set the sql for sorting the list
if ($user_view) {
	if ($user_view == "all") {
		$sql_where = "";
	}else {
		$sql_where = "WHERE per_id = '$user_view'";
	}
}
if ($user_order) {
	if ($user_order == "2") {
		$sql_order = "DESC";
	} else {
		$sql_order = "ASC";
	}
}

//Retrieve permission names from database
get_pernames($conn);

//echo "<br>Id here is: $user_id";

$user_list = "<table><tr><th class=table_header>Name
								<th nowrap class=table_header>Work No.
								<th nowrap class=table_header>E-Mail
								<th nowrap class=table_header>Username
								<th nowrap class=table_header>Permissions
								<th nowrap class=table_header>Department
								<th nowrap class=table_header>Building
								<th nowrap class=table_header>Site
							</tr>";

$sql = "SELECT user_id, f_name, l_name, work_num, email, username, per_id, dept_id, build_id, site_id FROM help_users $sql_where ORDER BY $user_sorted $sql_order";
//echo $sql;
$result = mysql_query($sql,$conn);
while ($row = mysql_fetch_array($result)) {
	$user_id_dis = $row['user_id'];
	$f_name = $row['f_name'];
	$l_name = $row['l_name'];
	$work_num = $row['work_num'];
	$email = $row['email'];
	$username_temp = $row['username'];
	$per_id_temp = $row['per_id'];
	$dept_id = $row['dept_id'];
	$build_id = $row['build_id'];
	$site_id = $row['site_id'];

	if (!$alt) {
		$alt = "1";
	}
	if ($alt == "1") {
		$alt = "2";
		$chg = "<strong>";
	} else if ($alt == "2") {
		$alt = "1";
		$chg = "";
	}

	if ($per_id_temp) {
		if ($per_id_temp == '1') { $per_name = $per1_id; }
		if ($per_id_temp == '2') { $per_name = $per2_id; }
		if ($per_id_temp == '3') { $per_name = $per3_id; }
		if ($per_id_temp == '4') { $per_name = $per4_id; }
		if ($per_id_temp == '5') { $per_name = $per5_id; }
	}

	if ($user_sorted == "l_name") {
		$name_order = "$l_name $f_name";
	} else {
		$name_order = "$f_name $l_name";
	}
	$link = "";

	$user_list .= "
		<tr>
		<td nowrap>$chg <a class=name_sml href='/helpdesk/scripts/admin/admin_deluser.php?select_userid=$user_id_dis'>$name_order</a>
		<td nowrap>| $chg <a class=user_sml href='/helpdesk/scripts/admin/admin_deluser.php?select_userid=$user_id_dis'>$work_num</a>
		<td nowrap>| $chg <a class=user_sml href='/helpdesk/scripts/admin/admin_deluser.php?select_userid=$user_id_dis'>$email</a>
		<td nowrap>| $chg <a class=pass_sml href='/helpdesk/scripts/admin/admin_deluser.php?select_userid=$user_id_dis'>$username_temp</a>
		<td nowrap>| $chg <a class=pass_sml href='/helpdesk/scripts/admin/admin_deluser.php?select_userid=$user_id_dis'>$per_name</a>
		<td nowrap>| $chg <a class=other_sml href='/helpdesk/scripts/admin/admin_deluser.php?select_userid=$user_id_dis'>$dept_id</a>
		<td nowrap>| $chg <a class=other_sml href='/helpdesk/scripts/admin/admin_deluser.php?select_userid=$user_id_dis'>$build_id</a>
		<td nowrap>| $chg <a class=other_sml href='/helpdesk/scripts/admin/admin_deluser.php?select_userid=$user_id_dis'>$site_id</a>
			
		</tr>";
}


$bottom = "
<form method=get action=$phpself>
<table>
<h3>Please select a User to remove:</h3>
<tr class=standard><td nowrap class=bluetext>View $view_select Groups, Sorted $sorted_select in $order_select order.
<input type=submit name=submit value='Go'>
</table>
</form>

<table>
$user_list
</table>
";
//echo "<br>Main User View2: $user_view";
//echo "<br>IS Set?:  $user_order_isset";
include($DOCUMENT_ROOT.'/helpdesk/include/template.inc.php');
?>
Return current item: Helpdesk Solutions