5tarl0rd

Current Path : /home/tiporg/www/manage/
Upload File :
Current File : /home/tiporg/www/manage/members.php

<?php

include("classes/access_user_class.php"); 

header("Cache-Control: public");



$page_protect = new Access_user;

 //$page_protect->login_page = "login.php"; 

$page_protect->access_page(); 



if (isset($_GET['action']) && $_GET['action'] == "log_out") {

	$page_protect->log_out(); // the method to log off

}



if(isset($_REQUEST["st"]))

{

	$st = $_REQUEST["st"];

	mysql_query("update tbl_user set status = '".$st."' where user_id = '".$_REQUEST['id']."'");

}



if(isset($_POST["delete"]))

{

	if(isset($_POST["sno"]))

	{

	

 

  foreach($_POST["sno"] as $mem_id)

		{

			$sql = "delete from tbl_user where user_id = '$mem_id'"; 

			mysql_query($sql) or die(mysql_error());

		}

		 



	}

	else

	{

		$mess = "Please select any Record";

	}

}

########### select by department ################

if(isset($_REQUEST['deptt']))

{

	$_SESSION['depttchk'] = $_REQUEST['deptt'];

}



if(isset($_SESSION['depttchk']) && $_SESSION['depttchk'] != "all")

{

	$where = " where department = '".$_SESSION['depttchk']."'";

}

elseif(isset($_SESSION['depttchk']) && $_SESSION['depttchk'] == "all")

{

	$where = "";

	unset($_SESSION['depttchk']);

}

else

{

	$where = "";

	unset($_SESSION['depttchk']);

}

########### select by department ################



########### Sorting Code #############

if(isset($_REQUEST['action']) && $_REQUEST['action']=='down' && $_REQUEST['id'] != "")

{

      	$user_id1 = $_REQUEST['id'];

		$sort_order1 = $_REQUEST['sort'];

		

     	$query  =  "SELECT  user_id, `sort_order` FROM tbl_user where sort_order < '".$_REQUEST['sort']."' and department = '".$_REQUEST['depart']."' limit 1"; 

        $result  =  mysql_query($query);

       	$row  =  mysql_fetch_array($result);

		

		$user_id2 = $row['user_id'];

		$sort_order2 = $row['sort_order'];

        

		

		if($sort_order2 != "")

		{

			$str="update tbl_user set `sort_order` ='".$sort_order2."' where user_id=". $user_id1 ;

			mysql_query($str);

			$str2="update tbl_user set `sort_order`='".$sort_order1."' where user_id=". $user_id2 ;

			mysql_query($str2);

		}

	    header("Location: ".$_SERVER['HTTP_REFERER']);

	}



if(isset($_REQUEST['action']) && $_REQUEST['action']=='up' && $_REQUEST['id'] != "")

{

		

		$user_id1 = $_REQUEST['id'];

		$sort_order1 = $_REQUEST['sort'];

		

     	$query  =  "SELECT  user_id, `sort_order` FROM tbl_user where sort_order > '".$_REQUEST['sort']."' and department = '".$_REQUEST['depart']."' limit 1"; 

        $result  =  mysql_query($query);

       	$row  =  mysql_fetch_array($result);

		

		$user_id2 = $row['user_id'];

		$sort_order2 = $row['sort_order'];

		

		

		 

		if($sort_order2 != "")

		{

			$str="update tbl_user set `sort_order`='".$sort_order2."' where user_id=". $user_id1 ;

			mysql_query($str);

			$str2="update tbl_user set `sort_order`='".$sort_order1."' where user_id=". $user_id2 ;

			mysql_query($str2);

			

		}

		header("Location: ".$_SERVER['HTTP_REFERER']);

			

	}

########### Sorting Code #############



?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>All Members</title>

<link href="css/main.css" rel="stylesheet" type="text/css" />

<script language="javascript" src="js/validator.js" type="text/javascript"></script>

<script language="javascript">

function CheckAll(form)

{

	form= document.getElementById(form);

	for (var i = 0; i < form.elements.length; i++)

	{    

    	eval("form.elements[" + i + "].checked = true ");  

    } 



}  

function unCheckAll(form)

{

	form= document.getElementById(form);

	for (var i = 0; i < form.elements.length; i++)

	{    

		eval("form.elements[" + i + "].checked = false ");  

    } 

}

function doPost( frm )

{

	document.forms[frm].submit();

}



function confirmSubmit()

{

var agree=confirm("Are you sure you want to delete this record?");

if (agree)

	return true ;

else

	return false ;

}



 

 

 

 

 function checkthis()

{







	if(document.getElementById('usertype').options[document.getElementById('usertype').selectedIndex].value=='All'  )

	{

		

		

	}

	

 }

 function check(){

	

	var xind=document.getElementById("carid");

		var objselbar = xind.selectedIndex;

		document.form.action = "submitarticle.php?id="+ xind.options[objselbar].value+"";

		document.form.submit();

	

	}

	

	function filters()

	{

		document.forms["navform"].submit();

	}

</script>







</head>

<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">

<?php include("includes/header.php");?>

<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">

  <tr>

    <td rowspan="3" align="left" background="images/white_left_bar.gif"></td>

    <td align="center"></td>

    <td width="1%" rowspan="3" align="right" background="images/white_right_bar.gif">&nbsp;</td>

  </tr>

  <tr>

    <td>&nbsp;</td>

  </tr>

  <tr>

    <td width="99%"><table width="98%" border="0" align="center" cellpadding="2" cellspacing="2">

    

        <tr>

          <td width="20%" valign="top"><?php require_once("includes/left_column.php");?></td>

          <td width="80%" valign="top">

          

          

          

          <form name='navform' id='navform' method='post' >

		  <table width="100%" border="0" align="center" cellpadding="2" cellspacing="2" bordercolor="#cccccc" class="tableBorder">

              <tr>

                <td align="center" bgcolor="#EFEFEF" class="boldText">List all Users/Members </td>

              </tr>

             

             <tr>

                  <td><table width="100%" border="0" cellpadding="5">

                      <tr>

                        <td width="8%"><strong>Filter By:</strong> </td>

                        <td width="92%">

							<select name="deptt" id="deptt" onchange="filters();">

							<option value="">- - - - - - - - - - Select Here - - - - - - - - - -</option>

							<option value="all">All</option>

							<?php

							$res_dept = mysql_query("SELECT subcat_id,sub_title,url_code FROM `tbl_subcats`order by sub_title ASC");

							while($rwd = mysql_fetch_array($res_dept))

							{

							?>

							<option value="<?php echo $rwd['subcat_id'];?>" <?php if(isset($_SESSION['depttchk']) && $_SESSION['depttchk']==$rwd['subcat_id']) { echo "selected='selected'";}?>><?php echo $rwd['sub_title'];?></option>

							<?php

							}

							?>

                        	</select>

						 

                        </td>

                      </tr>

                    </table></td>

                </tr>

             

             

             

             

                <td align="left" background="#F6F6F6" class="boldBodyText">

				

                    <table width="100%" border="0" id='tbl'>

                      <tr>

                        <td width="30%"></td>

                      </tr>

                       <?php

					  	if (isset($mess)) {

					  ?>

					  <tr>

					  	<td class="error">

							<?php echo $mess; ?>						</td>

					</tr>

					<?php

						}

					?>	

					   

                     

					  <?php

					  	if (isset($_GET['mess'])) {

					  ?>

					  <tr>

					  	<td class="message">

							<?php echo $_GET['mess']; ?>						</td>

					</tr>

					<?php

						}

					?>	

                      <tr>

                        <td class="">

                      <?php

					  

					//define("NUM_ROWS", 10);

                	$test = new MyPagina;

					$test->sql =  "SELECT * FROM tbl_user $where order by sort_order DESC";  

					$result = $test->get_page_result(); // result set

					$num_rows = $test->get_page_num_rows(); // number of records in result set 

					$nav_links = $test->navigation(" | ", "currentStyle"); // the navigation links (define a CSS class selector for the current link)

					$nav_info = $test->page_info("to"); // information about the number of records on page ("to" is the text between the number)

					$simple_nav_links = $test->back_forward_link(true); // the navigation with only the back and forward links, use true to use images

					$total_recs = $test->get_total_rows(); // the total number of records	

					$showing = $test->page_info();		   

				   

						

						if( $num_rows == 0 )

						{

							$content = "

									<table cellspacing='1' cellpadding='1' border='0' width='100%' align='center' class='bodyTableBorderGray'>

										<tr >

										<td align='center' 'nowrap' >No Records Found.</td>

										</tr>

										</table>";

						}

						else

						{

						//##### Dispplay Action Links

						$content = "

									<table cellspacing='1' cellpadding='1' border='0' width='100%' align='center' class='bodyTableBorderGray'>

									<tr >";

						$content .= "

								<td align='center' 'nowrap' class='tableheading' >No</td>

								<td align='left' 'nowrap' class='tableheading' >Name</td>

								<td align='left' 'nowrap' class='tableheading' >Designation</td>

								<td align='left' 'nowrap' class='tableheading' >Email</td>

								

								<td align='center' 'nowrap' class='tableheading' >Up</td>

								<td align='center' 'nowrap' class='tableheading' >Down</td>

								<td align='center' 'nowrap' class='tableheading' >Status</td>

								<td align='center' 'nowrap' class='tableheading' >View</td>

								<td align='center' 'nowrap' class='tableheading' >Edit</td>

								<td align='center' 'nowrap' class='tableheading' >Delete</td>

								</tr>";

						

												

									

								//End HEader

								$count = 1;

								$alt_row_bg = "RowColor";

								

								for ($i = 0; $i < $num_rows; $i++) 

								{							

								

									//####### Display Data ###########33333

									if( $count % 2 == 0 )

									{

										$alt_row_bg = "AlternateRowColor"; //if record is even then display alternate color

									}

									else

									{

										$alt_row_bg = "RowColor"; //if record is even then display alternate color

									}

									$mem_id = mysql_result($result,$i,"user_id");

									$name = mysql_result($result,$i,"name");

									$email = mysql_result($result,$i,"email");

									$desig = mysql_result($result,$i,"designation");

									$depart = mysql_result($result,$i,"department");

									$sort = mysql_result($result,$i,"sort_order");

									$status = mysql_result($result,$i,"status");

									 

									if($status == 0)

									{

										$status = "<a href='members.php?id=".$mem_id."&st=1' style='color:red;'>Disable</a>";

									}

									else 

									{

										$status = "<a href='members.php?id=".$mem_id."&st=0' style='color:green;'>Enable</a>";

									}

									

									

									

									$content .= "<tr class='$alt_row_bg'>

												<td align='left'><input name='sno[]' id='sno[]' type='checkbox' value='{$mem_id}' /></td>

												<td align='left'>{$name}</td>

												<td align='left'>{$desig}</td>

												<td align='left'>{$email}</td>

												

												<td align='center'><a href='members.php?id=$mem_id&sort=$sort&depart=$depart&action=up'><img src='images/icons/up.png' border='0'></a></td>

												<td align='center'><a href='members.php?id=$mem_id&sort=$sort&depart=$depart&action=down'><img src='images/icons/down.png' border='0'></a></td>

												

												<td align='center'>{$status}</td>

												<td align='center'><a href='view_member.php?id=$mem_id'><img src='images/icons/view.gif' border='0'></a></td>

												<td align='center'><a href='edit_member.php?id=$mem_id'><img src='images/icons/edit.gif' border='0'></a></td>

												<td align='center'><a href='delete_member.php?id=$mem_id' onclick='return confirmSubmit()'><img src='images/icons/delete.gif' border='0'></a></td>

												</tr>";

										

											

															

									$count++;	

							}

								$content .= "</table>";

						}	

						$recordtext = $showing ;

						?>						</td>

                      </tr>

					  </table>

                  </td>

					 </tr>

                    <tr>

                        <td align="left" class="boldText"><?php echo $nav_links; ?></td>

                      </tr>

                      <tr>

                        <td align="left" ><?php echo $content; ?></td>

                      </tr>

                      <tr>

                        <td align="left" class="boldText" ><?php echo $nav_links; ?> </td>

                      </tr>

                      <tr>

                        <td></td>

                      </tr>

                      <?php if ($num_rows != "0") { ?>

                      <tr>

                        <td align="left" class="tableheading"><?php echo $recordtext; ?></td>

                      </tr>

                      <tr>

                        <td align="left"><a href='javascript:CheckAll("navform")'>Check All</a> | <a href='javascript:unCheckAll("navform")'>Uncheck All</a>&nbsp;

                          <input name="delete" value="Delete" id="delete" type="submit" onClick="return confirmSubmit()"/></td>

                      </tr>

                      <?php } ?>

                    

                 

            </table>

		  </form> 

       </td></tr>

      </table></td>

  </tr>

  <tr>

    <td ><img src="images/white_left_bottom_corner.gif" width="9" height="9" /></td>

    <td width="99%" background="images/white_bottom_bar.gif"><img src="images/white_bottom_bar.gif" width="4" height="9" /></td>

    <td width="1%"><img src="images/white_right_bottom_corner.gif" width="9" height="9" /></td>

  </tr>

</table>

</body>

</html>


5tarL0rd By 5tarl0rd Being Anonymous