
<?php
include '../../connect.php';
session_start();

$kadPengenalan= $_POST['kadPengenalan'];
$peranan =$_POST['peranan'];
$status =$_POST['status'];
$ic=$_SESSION["kadPengenalan"];

date_default_timezone_set("Asia/Kuala_Lumpur");			
$date=date('Y-m-d');
$time=date('H:i:sa');

	if($peranan =="" || $status == "")
	{
		mysqli_commit($conn);
		echo "<script>alert('Sila lengkapkan maklumat. ');";
		echo "window.location.href = '../approvePage.php';</script>";
		exit;
		
	}
	else
	{
		$query="UPDATE user SET peranan_user='$peranan', status='$status' WHERE kad_pengenalan='$kadPengenalan' ";
		$strQuery = mysqli_query($conn,$query);
		
		if($strQuery) 
			{
				$q4="INSERT INTO audit_trail(kad_pengenalan,tarikh,masa,operasi,catatan)
						VALUES ('$ic','$date','$time','Approve','Approve pengguna')";
				$strQuery1 = mysqli_query($conn,$q4);
				
				if($strQuery1)
				{								
					echo "<script>window.location.href = '../approvePage.php';</script>";
					exit;
				}
				else{
					
				}
				
			}
			else
			{
				mysqli_commit($conn);
				echo "<script>alert('Sila lengkapkan maklumat pendaftaran. ');";
				echo "window.location.href = '../approvePage.php';</script>";
				exit;
				
			}
	}
?>

