<?php 	include_once('../../config.php');   	
		include_once(ABS_PATH.'/admin/login_check.php');    
        include ABS_PATH.'/admin/header.php';	
        
                if($_REQUEST['payAll']==1)
                { 
                    /*
                        $stmt=$conn->prepare("update UI__DailyROIGene set  PaidDate=:PaidDate ,paidStatus =1 where custId=:custId and PaidDate='' ");  
                        $stmt->bindValue(':PaidDate',  date("d-M-Y") , PDO::PARAM_STR);
                        $stmt->bindValue(':custId', $_REQUEST['id'] , PDO::PARAM_STR);
                        //$stmt->execute();  
                        //header("Location: tradingPay.php?id=".$_REQUEST['id']." ");
                       // die;*/
                }
                
                
                 
                if($_REQUEST['updatePay']==1)
                {      
                    $stmt=$conn->prepare("update UI__DChstr set  paidStatus=1 where id=:id  ");  
                    $stmt->bindValue(':id', $_REQUEST['Mid'] , PDO::PARAM_STR); 
                    $stmt->execute();  
                     
                    $stmt=$conn->prepare("update UI__DailyROIGene set  PaidDate=:PaidDate ,paidStatus =1 where custId=:custId and PaidDate='' and TopUpdate=:TopUpdate ");  
                    $stmt->bindValue(':PaidDate',  date("d-M-Y") , PDO::PARAM_STR);
                    $stmt->bindValue(':custId', $_REQUEST['id'] , PDO::PARAM_STR);
                    $stmt->bindValue(':TopUpdate', $_REQUEST['tdt'] , PDO::PARAM_STR);  
                    $stmt->execute();  
                    header("Location: tradingPay.php?id=".$_REQUEST['id']." ");
                    die;
                }
?>  

<script>
var URL  = '<?php echo ROOTPATH;?>';  
function del_record(val)
{

    
	var r = confirm("Do you really want to delete record !");
	if (r == true) {    
	$.ajax({
	type: 'POST',
	    url: URL+"/admin/ajax/default.php",
	//async: false,			 
	data: {PayTrading:1,val:val},	  
	success: function(ajaxresult){	     
		location.reload();	 	
	},
	error: function(XMLHttpRequest, textStatus, errorThrown) { 
	alert('Error');
	}
	});
	
	}	 
} 
</script>
		 
		<div class="col-md-10">  
  			<div class="content-box-large">
  				<div class="panel-heading">
					<div class="panel-title"><h3> Trading Income Details</h3></div>
					
					<div align="right"> 
					        <input type="button"  class="btn btn-warning" name="btnback" id="btnback" value=" Back " onClick="javascript:location.href='registered_users.php';" /> 
					        <a class="btn btn-warning"   onClick="javascript:location.href='tradingPay.php?payAll=1&id=<?php echo $_REQUEST['id'];?>';" > PayAll</a> 
					         
					</div>
					
				</div>
				
  				<div class="panel-body">
  					<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
						<thead>
							<tr>
    							<th>Sr</th>  
    							<th>By</th> 
    							<th>Name</th> 
    							<th>Auto Withdraw</th> 
    							<th>Received</th> 
    							<th>Bank</th> 
    							<th>Account</th> 
    							<th>IFSC</th> 
    							<th>Date</th>    
    							<th>Pay</th>  
							</tr>
						</thead>
						<tbody>
							<?php
                                    $stmt=$conn->prepare("select  * from UI__DailyROIGene  where custId=:custId");  
                                    $stmt->bindValue(':custId', $_REQUEST['id'] , PDO::PARAM_STR);
                                    $stmt->execute(); 
                                    $AllUsers = $stmt->fetchAll(PDO::FETCH_OBJ); 
                                    $sr = 1;  
								  foreach($AllUsers as $users)
								  {   
                                        $stmt=$conn->prepare("select  *  from UI__Rgst  where cuurentId=:cuurentId");  
                                        $stmt->bindValue(':cuurentId', $users->custId , PDO::PARAM_STR);
                                        $stmt->execute(); 
                                        $UI__Rgst = $stmt->fetch(PDO::FETCH_OBJ);    
                                        
                                        
                                    
                                        
                                        
							?>
							<tr class="odd gradeX">
								<td><?php echo $sr++;?> </td>
								<td><?php echo $users->custId;?> </td>
								<td><?php echo $UI__Rgst->nm;?> </td>
								<td><?php echo $users->amount;?> </td>
								<td><?php echo ($users->amount)-(($users->amount*10)/100);?> </td>
								<td><?php echo $UI__Rgst->Bname;?> </td>
								<td><?php echo $UI__Rgst->Bnumber;?> </td>
								<td><?php echo $UI__Rgst->Bifsc;?> </td>
								<td><?php echo $users->PaidDate;?> </td> 
								<td> 
								    <?php if($users->paidStatus==1) { ?>
								            Paid 
								    <?php }else { ?>  
								        <a href="javascript:void(0);">Pay Now</a>
								    <?php }?>
								</td> 
							</tr>  
							<?php } ?>
						</tbody>
					</table>
  				</div>
  				
  				
  				
  				<div class="panel-body">
  					<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
						<thead>
							<tr>
    							<th>Sr</th>  
    							<th>Amount</th> 
    							<th>Date</th> 
    							<th>Id </th> 
    							<th>Status</th>   
							</tr>
						</thead>
						<tbody>
							<?php
                                    $stmt=$conn->prepare("select  * from UI__DChstr  where Rid=:Rid and typ=1");  
                                    $stmt->bindValue(':Rid', $_REQUEST['id'] , PDO::PARAM_STR);
                                    $stmt->execute(); 
                                    $AllUsers = $stmt->fetchAll(PDO::FETCH_OBJ); 
                                    $sr = 1;   
                                    
								  foreach($AllUsers as $users)
								  {     
								      
                                        $Tdt = date("d-M-Y", strtotime($users->Tdate));  
                                        
							?>
							<tr class="odd gradeX">
								<td><?php echo $sr++;?> </td>
								<td><?php echo $users->amt;?> </td>
								<td><?php echo $users->Tdate;?> </td>
								<td><?php echo $_REQUEST['id'];?> </td> 
								<td> 
								    <?php if($users->paidStatus==1) { ?>
								            Paid 
								    <?php }else { ?>
								        <a href="tradingPay.php?updatePay=1&id=<?php echo $_REQUEST['id'];?>&Mid=<?php echo $users->id;?>&tdt=<?php echo $Tdt;?>">Pay Now</a>
								    <?php }?>
								</td> 
							</tr>  
							<?php } ?>
						</tbody>
					</table>
  				</div>
  				
  				
  			</div>   
		  </div>
		</div>
    </div> 
<?php  include ABS_PATH.'/admin/footer.php';	?>    