<?php

 include"initialize_page.php";
 		
	if(isset($_REQUEST['id'])&&$_REQUEST['id']!="")
	{
		$id=$_REQUEST['id'];
		
		//test mail
		$test_q = mysqli_query($con,"SELECT * FROM x_investment 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);
			  $user_id = $test_array['x_userid'];
			  $interest_request =  $test_array['x_interestreq'];
			  $interest_earn = $test_array['x_interestearn'];
			  $interest_earn = number_format($interest_earn,2);
			  $invest_amount = $test_array['x_invamount'];
			  $invest_amount = number_format($invest_amount,2);
			  $total_amount = $test_array['x_totalearn'];
			  $total_amount = number_format($total_amount,2);			  
			  $main_currency = main_account_currency($user_id);
				 
			 
			   
?>
<!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 type="text/javascript">
		
	function approve_investment(id,userid,investamount)
	 {
		 
		     //alert(investamount);
			var r = confirm("Are you sure to Approve Loan??");
			if(r==true)
			{
			$.post("controller.php", {id:id,userid:userid,investamount:investamount,q:"approve_investment"} , function(data)
			{
				
		    if(data =="minbal"){
				alert("User does not have sufficient balance...")
			}
			window.location.href='<?php   echo website_settingdata('x_weburl'); ?>admin/investment.php';  
			});
			}
		
	}

 </script>
    
</head>
<body>	
	<?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 class="btn btn-danger" onClick="approve_investment(<?php echo $id;?>,<?php echo $user_id;?>,<?php echo $test_array['x_invamount']; ?>)">Approve</button></td>
				
                    </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  user_bankuser($user_id,"x_userid");?></td>     
                                </tr>
                                
                            <tr class="odd gradeX">
                                <td width="24%">First Name</td>
                                <td width="76%"><?php echo  user_bankuser($user_id,"x_fname");?></td>     
                            </tr>
                            <tr class="odd gradeX">
                                <td width="24%">Last Name</td>
                                <td width="76%"><?php echo  user_bankuser($user_id,"x_lname");?></td>     
                            </tr>

                               <tr class="odd gradeX">
                                    <td>Email</td>
                                    <td><?php echo  user_bankuser($user_id,"x_email");?></td>     
                                </tr>
                                 <tr class="odd gradeX">
                                    <td>Phone Number</td>
                                    <td><?php echo  user_bankuser($user_id,"x_phonenumber");?></td>     
                                </tr>
                              
                                 <tr class="odd gradeX">
                                    <td>Date of Birth</td>
                                    <td><?php echo  user_bankuser($user_id,"x_dob");?></td>     
                                </tr>
                                 <tr class="odd gradeX">
                                    <td>Image</td>
                                    <td><img src="<?php   echo website_settingdata('x_weburl');   ?>user/pics/<?php echo  user_bankuser($user_id,"x_pic");?>" style="width:60px;height:60px;"></td>     
                                </tr>
                                 <tr class="odd gradeX">
                                    <td>Address</td>
                                    <td><?php echo  user_bankuser($user_id,"x_address");?></td>     
                                </tr>
								 <tr class="odd gradeX">
                                    <td>Investment Amount</td>
                                    <td><?php echo $main_currency ?>  <?php echo $invest_amount; ?></td>     
                                </tr>
								<tr class="odd gradeX">
                                    <td>Investment Period</Dtd>
                                    <td><?php echo $test_array['x_invperiod']; ?></td>     
                                </tr>
								<tr class="odd gradeX">
                                    <td>Interest</td>
                                    <td><?php echo  $test_array['x_interest']; ?> %</td>     
                                </tr>
								<tr class="odd gradeX">
                                    <td>Interest Request</td>
									
                                    <td><?php  
									if($interest_request ==1)
									{
									   echo "Annualy";
									} 
									elseif($interest_request ==2)
									{
									   echo "Semi Annualy";
									} 
									elseif($interest_request ==4)
									{
									   echo "Quatarly";
									}
									elseif($interest_request ==12)
									{
									   echo "Monthly";
									}
									 ?></td>     
                                </tr>
								<tr class="odd gradeX">
                                    <td>Earn Interest</td>
                                    <td><?php echo $main_currency ?>  <?php echo  $interest_earn; ?></td>     
                                </tr>
								
                                 <tr class="odd gradeX">
                                    <td>Total Amount</td>
                                    <td><?php echo $main_currency ?>  <?php echo $total_amount; ?></td>   
                                </tr>
								

                            </tbody>
                        </table>
						
						  

                    </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();
}
?>