<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Approval list</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-Pwb0n8JH0BDI+u+S5vW5vGnwP5cTrhMOzoJ54oIT1ed2bLE8kvUd9JyA4uJSqcMXT0KtJd65fAMTyyF8SkVTKQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />

<style>
  .card {
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 20px;
    width: 120vh;
    margin: 30px auto;
    background-color: white;
  }

 

.buttonclss {
    color: white;
    width: 65px;
    background-color: #00cc44;
    height: 32px;
    border: none;
    border-radius: 8px;
    transition: background-color 0.3s ease; /* Add transition for smooth effect */
	
}

.buttonclss:hover {
    background-color: #008000; /* Change to a darker shade of green on hover */
}
.bckbntnn
{
	color: white;
    width: 65px;
    background-color:gray;
    height: 32px;
    border: none;
    border-radius: 8px;
    transition: background-color 0.3s ease; /* Add transition for smooth effect */
	float:right;
}
.bckbntnn:hover {
	color:white;
    background-color:black; /* Change to a darker shade of green on hover */
}
.approved
{
   color: white;
    width: 80px;
    background-color:#00cc66;
    height: 32px;
    border: none;
    border-radius: 8px;
    transition: ba	
}
.approved:hover
{
	
    background-color:#008040; /* Change to a darker shade of green on hover */
}
.rejects
{
	color: white;
    width: 80px;
    background-color:#ff0000;
    height: 32px;
    border: none;
    border-radius: 8px;
    transition: ba	
}
.rejects:hover
{
	    background-color:#b30000; /* Change to a darker shade of green on hover */



}

 .popup-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 9999;
  }
</style>
</head>
<body>
 <button type="button" id="backbtn" class="bckbntnn" onclick="bacckfun();">Back</button>

  <h2>User Details</h2>
  <?php
  
  session_start();

require("connect.php");	

$username = $_SESSION['username'];
 $rolemaster_id = $_SESSION['rolemaster_id'];
 
 $id=$_REQUEST['id'];
 
 $sql2 = $con->query("SELECT * FROM `user_master`where id='$id'");

      $profiledtils = $sql2->fetch(PDO::FETCH_ASSOC);
	  
		 
		  
		  $rolemasterid=$profiledtils['role_master_id'];

		  $pic=$con->query("SELECT * FROM `profile_photo_uploaded` where rolemaster_id='$rolemasterid'");
		  $profilepic = $pic->fetch(PDO::FETCH_ASSOC);
			
			
  ?>
 <div style="display:flex;justify-content:space-between;">
<label style="font-size:20px;"><img src="/rythm/assets/user-account.png" style="height:25px;width:25px;">&nbsp;<?php echo  ucfirst($profiledtils['name'].''.$profiledtils['last_name']); ?></label>
<label  style="font-size:20px;"><img src="/rythm/assets/gmail.png" style="height:25px;width:25px;">&nbsp;&nbsp;<?php echo  ucfirst($profiledtils['email']); ?></label>
</div><br>

<div style="display:flex;justify-content:space-between;">
<label  style="font-size:20px;"><img src="/rythm/assets/call.png" style="height:25px;width:25px;">&nbsp;&nbsp;<?php echo  $profiledtils['mobile_no']; ?></label>
<label  style="font-size:25px;"><img src="/rythm/assets/title.png" style="height:30px;width:30px;">&nbsp;<?php echo  ucfirst($profiledtils['title']); ?></label>
<label  style="font-size:20px;"><img src="/rythm/assets/gps.png" style="height:28px;width:28px;"><?php echo  ucfirst($profiledtils['location']); ?></label>
</div>	

</div>
<br><br>
<label for="" style="text-align:center;font-size:35px;">profile-Pic</label><br><br>
<img src="<?php echo $profilepic['photo_path']?>" style="height:50px;width:50px;"><br><br>


<?php
if($profilepic['admin_status']==0)
{
?>
 <button type="button" id="approvedbtn" class="approved" onclick="approved(<?php echo $id;?>);">Approve</button>

 <button type="button" id="rejectbtn" class="rejects" onclick="rejects();" style="margin-left:50px;">Reject</button>
<?php
}
else if($profilepic['admin_status']==1)
{
?>
<label for="" style="font-weight:600;color:green;">Approved</label>
<?php
}
else if($profilepic['admin_status']==2)
{?>
<label for="" style="font-weight:600;color:red;">Rejected</label>

<?php
}?>
<div id="popupCard" class="popup-card">
<img src="/rythm/assets/blkcolorcross.png" style="height:25px;width:25px;float:right;" onclick="closepopcard();">
  <h3>Reason for Rejection</h3>
  <textarea id="rejectReason" rows="4" cols="50"></textarea><br><br>
  <button onclick="saveRejectionReason(<?php echo $id;?>)" class="approved">Save</button>
</div>
</body>
</html>
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
	<Script>
	
	
	
	function bacckfun()
	{
		window.location.href="/rythm/adminlogin/admin_approval_list.php";
	}
	function approved(id)
	{
		//debugger;
		$.ajax({
			url: 'approve_profilpic_sts.php?id='+id, // Replace with your server-side script URL
			type: 'POST',
			// Pass useriddd to the server
			success: function(data) {
				if(data==1)
				{
					alert('Approved For This Profile SuccessFully!..');
					window.location.href="/rythm/adminlogin/admin_approval_list.php";
				}
				else
				{
					alert('Not Approved For This Profile');
					window.location.href="/rythm/adminlogin/admin_approval_list.php";
				}
			
			
				//console.warn(data);
				//$('.card').html(data);
			},
			error: function(xhr, status, error) {
				// Handle errors
				console.error(xhr, status, error);
			}
		});
	}
</script>	
<script>
  function rejects() {
    document.getElementById('popupCard').style.display = 'block';
  }

  function saveRejectionReason() {
    var reason = document.getElementById('rejectReason').value;
    // Here you can handle saving the rejection reason with AJAX or other means
    console.log('Rejection Reason:', reason);
    // For now, let's close the popup card
    document.getElementById('popupCard').style.display = 'none';
  }
  
  
  function closepopcard()
  {
	 document.getElementById('popupCard').style.display = 'none'; 
  }
  function saveRejectionReason(id)
  {
	  var reason=$("#rejectReason").val();
	 $.ajax({
			url: 'rejected_profilepic_sts.php?id='+id, // Replace with your server-side script URL
			type: 'POST',
			data: {
            reason: reason // Pass the reason as data to the server
        },
			success: function(data) {
				if(data==1)
				{
					alert('Rejection For This Profile!..');
					window.location.href="/rythm/adminlogin/admin_approval_list.php";
				}
				else
				{
					alert('Not Rejection For This Profile');
					//window.location.href="/rythm/adminlogin/admin_approval_list.php";
				}
			
			
				//console.warn(data);
				//$('.card').html(data);
			},
			error: function(xhr, status, error) {
				// Handle errors
				console.error(xhr, status, error);
			}
		}); 
  }
</script>