<?php

 include"initialize_page.php";
 
	if(isset($_REQUEST['id'])&&$_REQUEST['id']!="")
	{
		$id=$_REQUEST['id'];
		//test mail
		$test_q=mysqli_query($con,"SELECT * FROM x_users WHERE x_id='$id'");
		$test_row=mysqli_num_rows($test_q);
		   if($test_row==0)
		   {
			   
		header("location:index.php");	
	exit();
		   }
		   else
		   {
			   $test_array=mysqli_fetch_array($test_q);
			   
			 
?>
<!DOCTYPE html>
<html lang="en">

<head>
  
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

	<title>View User</title>

	<!-- Bootstrap core CSS -->
	<link rel="stylesheet" href="assets/css/bootstrap/bootstrap.css" /> 

	<!-- datatables Styling  -->
    <link rel="stylesheet" href="assets/css/plugins/datatables/jquery.dataTables.css" />
    
    <!-- Fonts  -->
    <link href='http://fonts.googleapis.com/css?family=Raleway:400,500,600,700,300' rel='stylesheet' type='text/css'>
    
    <!-- Base Styling  -->
    <link rel="stylesheet" href="assets/css/app/app.v1.css" />

	<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via  -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
		<script>

		function useraction()
		{
				var action=$("#actionofaccounthh").val();
				var accid=$("#account_id").val();
				
        if(action=="")
				{
				  alert("Please Choose Action..");
					return false;	
				}
				else
				{
				  $.post("controller.php", { id:"<?php  echo $id;  ?>", q:"user_account_action", action:action,accid:accid } , function(data)
          {
	           alert("Action Successfully..");
              window.location.href='<?php   echo website_settingdata('x_weburl');   ?>admin/view_user.php?id=<?php  echo $id;  ?>';  
            });
				}
		}
    function changepass()
    {
        var password=$("#upass").val();
        var pin=$("#upin").val();
        if(password=="")
        {
          alert("Please Enter password to change");
          return false; 
        }
        else if(pin=="")
        {
          alert("Please Enter pin to change");
          return false; 
        }
        else
        {
          $.post("controller.php", { id:"<?php  echo $id;  ?>", q:"user_password_change", password:password,pin:pin } , function(data)
          {
             alert("Action Successfully..");
              window.location.href='<?php   echo website_settingdata('x_weburl');   ?>admin/view_user.php?id=<?php  echo $id;  ?>';  
            });
        }
    }
		</script>
    
</head>
<body>	





	<div class="modal fade" id="modal-form" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title" id="myModalLabel">User Account Action</h4>
          </div>
          <div class="modal-body">
            
            	 <div class="form-group">
                    <label for="exampleInputEmail1">Action</label>
                   <select name="actionofaccounthh" class="form-control" id="actionofaccounthh">
                   <option value="" selected>Select Action</option>
                   <option value="Y">Active</option>
                    <option value="N">InActive</option>
                 <option value="Restricted" >Restricted</option>
                      <option value="D">Delete</option>
                   </select>
                    
                  </div>
              
            
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            <input type="submit" class="btn btn-primary" value="Submit" name="sub" id="acctioninaccounts" onClick="useraction()"> 
          </div>
        </div>
      </div>
    </div>

    <div class="modal fade" id="modal-password" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title" id="myModalLabel">Change User Password and Pin</h4>
          </div>
          <div class="modal-body">
            <div class="form-group">
              <label for="exampleInputEmail1">Password</label>
              <input type="text" name="" id="upass"  class="form-control" value="<?php echo $test_array['x_password']; ?>"><br>
              <label for="exampleInputEmail1">Pin</label>
              <input type="text" name="" id="upin" class="form-control" value="<?php echo $test_array['x_acpin']; ?>">
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            <input type="submit" class="btn btn-primary" value="Submit" name="sub" id="acctioninaccounts" onClick="changepass()"> 
          </div>
        </div>
      </div>
    </div>
    
	<?php    include"xleftmenu.php"; ?>
    
    <section class="content">
    	
         <?php  include"xheader.php";  ?>
        <!-- Header Ends -->
        
        
        <div class="warper container-fluid">
        	
            <div class="page-header"><h1></h1></div>
            
            
            
                <div class="panel panel-default">
                    <div class="panel-heading">
                   
                    <div align="right">

                      <button type="button" class="btn btn-success btn-circle btn-flat" data-toggle="modal" data-target="#modal-password" style="background:gray;">Change Password</button>

                   
                    
                    </div>
                    </div>
                    <div class="panel-body">
                    
                        <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="basic-datatable">
                          
                            <tbody>
                            
                             
                                <tr class="odd gradeX">
                                    <td width="24%">UserID</td>
                                    <td width="76%"><?php echo $test_array['x_userid']; ?></td>     
                                </tr>
                                
                            <tr class="odd gradeX">
                                <td width="24%">First Name</td>
                                <td width="76%"><?php echo $test_array['x_fname']; ?></td>     
                            </tr>
                            <tr class="odd gradeX">
                                <td width="24%">Last Name</td>
                                <td width="76%"><?php echo $test_array['x_lname']; ?></td>     
                            </tr>

                               <tr class="odd gradeX">
                                    <td>Email</td>
                                    <td><?php echo $test_array['x_email']; ?></td>     
                                </tr>
                                 <tr class="odd gradeX">
                                    <td>Phone Number</td>
                                    <td><?php echo $test_array['x_phonenumber']; ?></td>     
                                </tr>
                              
                                 <tr class="odd gradeX">
                                    <td>Date of Birth</td>
                                    <td><?php echo $test_array['x_dob']; ?></td>     
                                </tr>
                                 <tr class="odd gradeX">
                                    <td>Image</td>
                                    <td><img src="<?php   echo website_settingdata('x_weburl');   ?>user/pics/<?php echo $test_array['x_pic']; ?>" style="width:60px;height:60px;"></td>     
                                </tr>
                                
                                 <tr class="odd gradeX">
                                    <td>Gender</td>
                                    <td><?php echo $test_array['x_gender']; ?></td>     
                                </tr>
                                 
                                
                                 <tr class="odd gradeX">
                                    <td>Address</td>
                                    <td><?php echo $test_array['x_address']; ?></td>     
                                </tr>
                                  <tr class="odd gradeX">
                                    <td>City Name</td>
                                    <td><?php echo $test_array['x_city']; ?></td>     
                                </tr>
                                  <tr class="odd gradeX">
                                    <td>State</td>
                                    <td><?php echo $test_array['x_state']; ?></td>     
                                </tr>
                                  <tr class="odd gradeX">
                                    <td>Zip Code</td>
                                    <td><?php echo $test_array['x_zip']; ?></td>     
                                </tr>
                               

                                <tr class="odd gradeX">
                                    <td>Account Password</td>
                                    <td><?php echo $test_array['x_password']; ?></td>     
                                </tr>

                                <tr class="odd gradeX">
                                    <td>Account Pin</td>
                                    <td><?php echo $test_array['x_acpin']; ?></td>     
                                </tr>
                            
                            </tbody>
                        </table>
						
						  

                    </div>
                </div>
                
                <div class="panel panel-default">
                    <div class="panel-body">
                    <form method="post">
                        <table class="table table-bordered">
							<thead>
							  <tr>
							    <th>No</th>
								<th>Account Type</th>
								<th>Account Number</th>
								<th>Account Status</th>
								<th>Account Action</th>
							  </tr>
							</thead>
							<tbody>
							  <?php
						  $sr=1;
						  
							   
							   {
						  
						      $data_q=mysqli_query($con,"SELECT * FROM x_anotheracc WHERE x_userid='$id' ORDER by x_id DESC");  
							  
							
							   }
			while($data_array=mysqli_fetch_array($data_q))
			{
				
			?>
							
							  <tr>
							       <td><?php echo $sr; ?></td>
								   <td><?php echo $data_array['x_actype']; ?></td>
								    
                                   <td><?php echo $data_array['x_time']; ?></td>     
                             
                                   <td><?php if($data_array['x_status']=="Y") { echo 'Active'; } else { 
				   if($data_array['x_status']=="N") 
				        {
							echo "Inactive";
							
						}
						 else  
				   if($data_array['x_status']=="Restricted") 
				        {
							echo "Restricted";
							
						}
						else
						{
							 if($data_array['x_status']=="D") 
							   {
								   
								   echo "Deleted";
							   }
							   else
							   {
								   echo $data_array['x_status'];
								   
							   }
							
						}
				     
				   
				 }  ?></td>
				                 <input type="hidden" name="account_id" id="account_id" value="<?php echo $data_array['x_id'];?>">
				                 <td><button type="button" class="btn btn-success btn-circle btn-flat" data-toggle="modal" data-target="#modal-form" style="background:gray;">Account Action</button></td>
							  </tr>
							</tbody>
			      <?php 
				    $sr++;
				  }?>
						  </table>
						
						  
</form>
                    </div>
                </div>
               
                
                
                
                
                
                
                
              
                
                
                
            
            
            
            
        </div>
        <!-- Warper Ends Here (working area) -->
        
        
        <footer class="container-fluid footer">
        	Copyright &copy; 2016
        </footer>
        
    
    </section>
    <!-- Content Block Ends Here (right box)-->
    
    
    
    <!-- JQuery v1.9.1 -->
	<script src="assets/js/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
    
    <!-- Bootstrap -->
    <script src="assets/js/bootstrap/bootstrap.min.js"></script>
    
    <!-- NanoScroll -->
    <script src="assets/js/plugins/nicescroll/jquery.nicescroll.min.js"></script>
    
    
	<!-- Data Table -->
    <script src="assets/js/plugins/datatables/jquery.dataTables.js"></script>
    <script src="assets/js/plugins/datatables/DT_bootstrap.js"></script>
    <script src="assets/js/plugins/datatables/jquery.dataTables-conf.js"></script>
    
    
    <!-- Custom JQuery -->
	<script src="assets/js/app/custom.js" type="text/javascript"></script>
    

    
	<script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    
    ga('create', 'UA-56821827-1', 'auto');
    ga('send', 'pageview');
    
    </script>
</body>
</html>
<?php
		   }
}
else
{
	
header("location:index.php");	
	exit();
}
?>