<?php
include"initialize_page.php";
include"systemfunctions.php";
?>
<?php include('resources/header.php') ?>
	<title></title>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
<?php include('resources/css-file.php') ?>
<?php include('resources/navigation.php') ?> 
<!-- Dashboard wrapper starts -->
<div class="dashboard-wrapper">
	<div class="main-container">				
		<div class="row">
			<div class="col-sm-12 ac-summ">
				<!--<h2>Account Summary</h2>-->
				<h3>Account Beneficiery</h3>
                
			</div>
			
		</div>
		</br>
		<div class="row gutter">
			<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">	
				
					<ul class="boxli">
						<li>
							<h2>Account Beneficiary List</h2>
							<p>View list of all of your account beneficiary. You can add upto 4 account beneficaries.</p>
							<p>If you want to add Account beneficairy then <a href="<?php  echo website_settingdata('x_weburl'); ?>user/add-beneficiary.php" style="color:blue;"> Click Here</a> </p>
							<div class="table-responsive">
								<table class="table table-bordered no-margin">
									<thead>
										<tr>
											<th>Full Name </th>
											<th>Email</th>
											<th>Phone</th>
											<th>Address</th>
											<th>ID Number</th>
											<th>ID (Type)</th>
											<th>Relation</th>
											<th>Edit</th>
											<th>Delete</th>
										</tr>
									</thead>
									<tbody>
										 <?php
											 $account_q=mysqli_query($con,"SELECT * FROM x_beneficiary WHERE x_userid='$user_id' ORDER by x_id DESC");
											 $account_row=mysqli_num_rows($account_q);
												  while($account_array=mysqli_fetch_array($account_q))
													{
														
										?>
										 <tr>

											<td>  <?php  echo $account_array['x_fullname'];  ?> </td>
											<td><?php  echo $account_array['x_emailid'];  ?></td>
											<td><?php  echo $account_array['x_phonenumber'];  ?></td>
										   <td><?php  echo $account_array['x_address'];  ?></td>
											<td><?php  echo $account_array['x_idnumber'];  ?></td>
										   <td><?php  echo $account_array['x_idtype'];  ?></td>
											<td><?php  echo $account_array['x_relation'];  ?></td>
											<td><a href="<?php  echo website_settingdata('x_weburl'); ?>user/edit-beneficiary.php?id=<?php  echo $account_array['x_id'];   ?>"><button class="btn btn-primary">Edit</button></a></td>
											 <td><button class="btn btn-danger" style="background:rgba(255,0,0,1);" onClick="deletebeni(<?php  echo $account_array['x_id'];   ?>)"> Delete</button></td>

										  </tr>
   
                    
	<?php
				}
	
	?>
									</tbody>
								</table> 
							</div>
							</br>
							  <?php
							   if($account_row==0)
							   {
							   ?>
                              <p><strong>You don't have any Beneficiary added. We recommend you to <a href="<?php  echo website_settingdata('x_weburl'); ?>user/add-beneficiary.php"> Add your account beneficiary.</a></strong></p>
                                 <?php
							   }
							   ?>
						</li>									
					</ul>
				
			</div>	
		</div>
	</div>		
	</br>
</div>
	<!-- Main container ends -->
<!-- Dashboard wrapper ends -->
<?php include('resources/footer.php') ?>
<?php include('resources/js-file.php') ?>
<script src="js/jQuery.style.switcher.js"></script>
<script type="text/javascript">
		
		
		function deletebeni(id)
		             {
						 //alert(id);
					   var r=confirm("Do you want to Delete this Beneficiary Detail..??");
  if(r==true)
  { 
  
               $.post("controller.php", { id:id, q:"remove_beneficiaryfrom"  }, function(data)
			     {
					 alert("Deleted Successfully..");
					 window.location.href='<?php  echo website_settingdata('x_weburl'); ?>user/accountbene.php';
				 }
			   );   	
		
		}	 
						 
					 }
		
		</script>