<?php 	include_once('../../config.php');   	
		include_once(ABS_PATH.'/admin/login_check.php');    
		
		
		
		    $_POST['note'] = 'NA';
		    if(isset($_POST['update']))
            {    
                    $stmt=$conn->prepare("select  * from   UI__USDTRest where id=:id ");  
                    $stmt->bindValue(':id', $_REQUEST['id'] , PDO::PARAM_STR);
                    $stmt->execute(); 
                    $AllUsers = $stmt->fetch(PDO::FETCH_OBJ); 
                    
                     
                    if($_POST['Status']==2) 
                    {     
                        $stmt=$conn->prepare("update  UI__USDTRest  set note=:note , status=:status  where id=:id ");  
                        $stmt->bindValue(':note', $_POST['noteDt'] , PDO::PARAM_STR);
                        $stmt->bindValue(':status', $_POST['Status'] , PDO::PARAM_STR);
                        $stmt->bindValue(':id', $_REQUEST['id'] , PDO::PARAM_STR); 
                        $stmt->execute();  
                         
                    } 
                    else if($_POST['Status']==1) 
                    {
                        
                       
                    if($AllUsers->PgTYpe==1)
                    {
                        
                			$_POST['cuurentId'] = $AllUsers->custId;
                			$_POST['AMMT']  = ($AllUsers->AMMT*90);
                			 
                                			       
                            $_SESSIONuserId =  "DP630936";
                            $_POST['cuurentId'] = trim($_POST['cuurentId']);        
                            $stmt=$conn->prepare("select  custId   from UI__Rgst where cuurentId =:cuurentId ");   
                            $stmt->bindValue(':cuurentId', $_POST['cuurentId'] , PDO::PARAM_STR);  
                            $stmt->execute(); 
                            $affected_rows_UI__DChstr = $stmt->rowCount();  
                            $FResult = $stmt->fetch(PDO::FETCH_OBJ);  
                			
                               
                            $data['Data'] =  $_POST['AMMT'];  
                            $stmt=$conn->prepare("select  availableFund  from  UI__Fundtransfer   where userid=:cuurentId order by id desc");  
                            $stmt->bindValue(':cuurentId', $_SESSIONuserId  , PDO::PARAM_STR);
                            $stmt->execute();  
                            $AllUsers = $stmt->fetch(PDO::FETCH_OBJ); 
                            $availableFund = 0;
                             
                            
                            $AllUsersT = GetBalance($_SESSIONuserId); 
                              
                			 
                            if($AllUsersT>=$data['Data']) 
                            {
                                $availableFund = 1;    
                                $totalAvaib = $AllUsers->availableFund;
                            }    
                            
                            $stmt=$conn->prepare("select id from UI__Rgst  where  cuurentId=:cuurentId  ");   
                            $stmt->bindValue(':cuurentId',  $_SESSIONuserId , PDO::PARAM_STR);  
                            $stmt->execute();
                            $UI__Rgst = $stmt->fetch(PDO::FETCH_OBJ);   
                            
                            $stmt =  $conn->prepare("select *  from  _pkCc__  where  Uxd=:Uxd ");   
                            $stmt->bindValue(':Uxd', $UI__Rgst->id, PDO::PARAM_STR);
                            $stmt->execute(); 
                            $RstUxd = $stmt->fetch(PDO::FETCH_OBJ);
                            $PAYWAllet =  GetBalance(); 
                            $verify = password_verify($AllUsersT, $RstUxd->bl1); 
                            
                            
                                
                            if( ($AllUsersT >= $data['Data'])  && ($data['Data']>=100) && ($affected_rows_UI__DChstr>0) )
                            {    
                                 
                                $Result = $stmt->fetch(PDO::FETCH_OBJ);    
                                $stmt=$conn->prepare("update  UI__PnMX set exp=1 where id=:id ");    
                                $stmt->bindValue(':id', $Result->id , PDO::PARAM_STR);  
                               // $stmt->execute(); 
                                     
                                $PlanAMt = $data['Data'] ;    
                                $stmt=$conn->prepare("select refId,custId,nm   from UI__Rgst where cuurentId =:cuurentId ");   
                                $stmt->bindValue(':cuurentId', $_POST['cuurentId'] , PDO::PARAM_INT);  
                                $stmt->execute(); 
                                 
                                  
                               
                                if($stmt->rowCount() > 0)
                                {     
                                    $Result = $stmt->fetch(PDO::FETCH_OBJ);   
                                    $userNm = $Result->nm;
                                    $CC = $Result->refId;
                                    $MyCust =  $Result->custId;
                                    $ard[] = $CC;
                                    for($i=0;$i<=9;$i++)
                                    {
                                        $stmt=$conn->prepare("select refId from UI__Rgst where cuurentId =:cuurentId ");   
                                        $stmt->bindValue(':cuurentId',$CC, PDO::PARAM_INT);  
                                        $stmt->execute();  
                                        if($stmt->rowCount() > 0)
                                        { 
                                            $Result = $stmt->fetch(PDO::FETCH_OBJ);   
                                            $CC = $Result->refId;
                                            $ard[] = $CC;
                                        }
                                    }  
                                }   
                                   
                                function Refcall($ref)
                                {
                                    global $conn;
                                    $stmt=$conn->prepare("select cuurentId   from UI__Rgst where refId =:cuurentId ");   
                                    $stmt->bindValue(':cuurentId', $ref , PDO::PARAM_INT);  
                                    $stmt->execute(); 
                                    $Result = $stmt->fetchAll(PDO::FETCH_OBJ);   
                                    return $Result;
                                }          
                				 
                                $totalAvaib -= $data['Data'];  
                                $stmt=$conn->prepare("insert into  UI__Fundtransfer (userid,Tdate,amt,availableFund,topUpId) values(:userid,:Tdate,:amt,:availableFund,:topUpId)    "); 
                                $stmt->bindValue(':userid', $_SESSIONuserId , PDO::PARAM_STR); 
                                $stmt->bindValue(':Tdate',date("d-M-Y H:i"), PDO::PARAM_STR); 
                                $stmt->bindValue(':amt',$data['Data'], PDO::PARAM_STR);  
                                $stmt->bindValue(':availableFund', $totalAvaib , PDO::PARAM_STR);  
                                $stmt->bindValue(':topUpId', $_POST['cuurentId'] , PDO::PARAM_STR);    
                                $stmt->execute();  
                                
                                $CoinVal = ($data['Data']);    
                                $stmt=$conn->prepare("insert into  UI__DChstr (typ,amt,Tdate,Rid,sId,percet,coin,byId) values(:typ,:amt,:Tdate,:Rid,:sId,:percet,:coin,:byId) ");   
                                $stmt->bindValue(':typ', 1, PDO::PARAM_INT); 
                                $stmt->bindValue(':amt', $data['Data'], PDO::PARAM_INT); 
                                $stmt->bindValue(':Tdate', date("d-M-Y H:i:s") , PDO::PARAM_STR); 
                                $stmt->bindValue(':Rid', $_POST['cuurentId']  , PDO::PARAM_STR);
                                $stmt->bindValue(':sId', $MyCust  , PDO::PARAM_STR);
                                $stmt->bindValue(':percet', 0  , PDO::PARAM_STR);  
                                $stmt->bindValue(':coin', 1  , PDO::PARAM_STR);   
                                $stmt->bindValue(':byId', $_SESSIONuserId  , PDO::PARAM_STR);     
                                $stmt->execute();   
                                     
                				 
                				$stmt=$conn->prepare("select refId,custId   from UI__Rgst where cuurentId =:cuurentId ");   
                                $stmt->bindValue(':cuurentId', $_POST['cuurentId'] , PDO::PARAM_INT);  
                                $stmt->execute(); 
                				$Dref = $stmt->fetch(PDO::FETCH_OBJ);   
                				
                                if($affected_rows_UI__DChstr < 1)
                                {
                				$stmt=$conn->prepare("insert into  UI__DChstr (typ,amt,Tdate,Rid,sId,level) values(:typ,:amt,:Tdate,:Rid,:sId,1) ");   
                				$stmt->bindValue(':typ', 7, PDO::PARAM_STR); 
                				$stmt->bindValue(':amt', (($data['Data']*5)/100) , PDO::PARAM_INT); 
                				$stmt->bindValue(':Tdate', date("d-M-Y H:i:s") , PDO::PARAM_STR); 
                				$stmt->bindValue(':Rid', $_POST['cuurentId'] , PDO::PARAM_STR);   
                				$stmt->bindValue(':sId', $Dref->refId, PDO::PARAM_STR);    
                				$stmt->execute(); 
                                }
                				
                				$stmt=$conn->prepare("select  custId from UI__Rgst where cuurentId =:cuurentId ");   
                                $stmt->bindValue(':cuurentId', $Dref->refId , PDO::PARAM_INT);  
                                $stmt->execute(); 
                				$MdRef = $stmt->fetch(PDO::FETCH_OBJ);    
                				 
                                LvBal($_SESSIONuserId,$_POST['AMMT'],2,"TopUp",$userNm." (".$_POST['cuurentId'].")");  
                                                     
                            	
                				$stmt=$conn->prepare("select  id from  UI__DChstr order by id desc  ");    
                				$stmt->execute();  
                				$UI__DChstrId = $stmt->fetch(PDO::FETCH_OBJ);
                				$DSCId = $UI__DChstrId->id;
                				 
                				
                				 if(end($ard)==0)
                                 {  
                                     
                                                    
                                    for($j1=0;$j1<(count($ard)-1);$j1++)
                                    {
                                        if($j1==0)
                                        {       
                                            
                                            
                                                    
                                                $CoinVal = ($data['Data']*0.1)/100;    
                                                $stmt=$conn->prepare("select id from UI__DChstr where Rid=:Rid and typ=1 and status=0 ");   
                                                $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();  
                                                
                                                
                 					                
                                                if($stmt->rowCount() > 0) 
                                                {    
                                                    $stmt=$conn->prepare("insert into  UI__Bns (Rid,Brid,Tdate,Tamt,BAmt,level,DaysLeft) values(:Rid,:Brid,:Tdate,:Tamt,:BAmt,:level,:DaysLeft) ");   
                                                    $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR); 
                                                    $stmt->bindValue(':Brid', $_POST['cuurentId'], PDO::PARAM_STR); 
                                                    $stmt->bindValue(':Tdate', date("d-M-Y") , PDO::PARAM_STR); 
                                                    $stmt->bindValue(':Tamt', $CoinVal , PDO::PARAM_STR);   
                                                    $stmt->bindValue(':BAmt', $data['Data'] , PDO::PARAM_STR);      
                                                    $stmt->bindValue(':level', 1  , PDO::PARAM_STR);       
                                                    $stmt->bindValue(':DaysLeft', 29  , PDO::PARAM_STR);   
                                                    $stmt->execute();   
                                                    
                                                    $stmt=$conn->prepare("select  * from  UI__Rgst where cuurentId=:cuurentId  ");   
                                                    $stmt->bindValue(':cuurentId',  $ard[$j1] , PDO::PARAM_STR);   
                                                    $stmt->execute();  
                                                    $custId = $stmt->fetch(PDO::FETCH_OBJ);
                                                    
                                                    
                                                    
                                                    
                                                    LvBal($ard[$j1],$CoinVal,1,"Level Balance",$_POST['cuurentId']);  
                                                    
                                                    $stmt=$conn->prepare("insert into  UI__LevlCt (tblId,custId,cct,bid) values(:tblId,:custId,:cct,:bid) "); 
                                                    $stmt->bindValue(':tblId',$DSCId, PDO::PARAM_STR); 
                                                    $stmt->bindValue(':custId',$_POST['cuurentId'], PDO::PARAM_STR); 
                                                    $stmt->bindValue(':cct',1, PDO::PARAM_STR);  
                                                    $stmt->bindValue(':bid', $ard[$j1] , PDO::PARAM_STR);   
                                                    $stmt->execute(); 
                                                    
                                                }
                                        }
                                        else if($j1==1)
                                        { 
                                            $CoinVal = ($data['Data']*0.05)/100;    
                                            $stmt=$conn->prepare("select id from UI__DChstr where Rid=:Rid and typ=1  and status=0 ");   
                                            $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR);   
                                            $stmt->execute();  
                                            if($stmt->rowCount() > 0) 
                                            {
                                                $stmt=$conn->prepare("insert into  UI__Bns (Rid,Brid,Tdate,Tamt,BAmt,level,DaysLeft) values(:Rid,:Brid,:Tdate,:Tamt,:BAmt,:level,:DaysLeft) ");   
                                                $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Brid', $_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tdate', date("d-M-Y") , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tamt', $CoinVal , PDO::PARAM_STR);   
                                                $stmt->bindValue(':BAmt', $data['Data'] , PDO::PARAM_STR);      
                                                $stmt->bindValue(':level', 2  , PDO::PARAM_STR);        
                                                $stmt->bindValue(':DaysLeft', 29  , PDO::PARAM_STR);   
                                                $stmt->execute();   
                                                
                                                $stmt=$conn->prepare("select  * from  UI__Rgst where cuurentId=:cuurentId  ");   
                                                $stmt->bindValue(':cuurentId',  $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();  
                                                $custId = $stmt->fetch(PDO::FETCH_OBJ);
                                                
                                                LvBal($ard[$j1],$CoinVal,1,"Level Balance",$_POST['cuurentId']);  
                                                
                                                $stmt=$conn->prepare("insert into  UI__LevlCt (tblId,custId,cct,bid) values(:tblId,:custId,:cct,:bid) "); 
                                                $stmt->bindValue(':tblId',$DSCId, PDO::PARAM_STR); 
                                                $stmt->bindValue(':custId',$_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':cct',1, PDO::PARAM_STR);  
                                                $stmt->bindValue(':bid', $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();
                                            }
                                             
                 					    }else if($j1==2)
                                        { 
                                            $CoinVal = ($data['Data']*(0.03))/100;   
                                            $stmt=$conn->prepare("select id from UI__DChstr where Rid=:Rid and typ=1  and status=0 ");   
                                            $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR);   
                                            $stmt->execute();  
                                            if($stmt->rowCount() > 0) 
                                            {
                                                $stmt=$conn->prepare("insert into  UI__Bns (Rid,Brid,Tdate,Tamt,BAmt,level,DaysLeft) values(:Rid,:Brid,:Tdate,:Tamt,:BAmt,:level,:DaysLeft) ");   
                                                $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Brid', $_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tdate', date("d-M-Y") , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tamt', $CoinVal , PDO::PARAM_STR);   
                                                $stmt->bindValue(':BAmt', $data['Data'] , PDO::PARAM_STR);      
                                                $stmt->bindValue(':level', 3  , PDO::PARAM_STR);        
                                                $stmt->bindValue(':DaysLeft', 29  , PDO::PARAM_STR);   
                                                $stmt->execute();   
                                                
                                                $stmt=$conn->prepare("select  * from  UI__Rgst where cuurentId=:cuurentId  ");   
                                                $stmt->bindValue(':cuurentId',  $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();  
                                                $custId = $stmt->fetch(PDO::FETCH_OBJ);
                                                
                                               LvBal($ard[$j1],$CoinVal,1,"Level Balance",$_POST['cuurentId']);  
                                               
                                                
                                                $stmt=$conn->prepare("insert into  UI__LevlCt (tblId,custId,cct,bid) values(:tblId,:custId,:cct,:bid) "); 
                                                $stmt->bindValue(':tblId',$DSCId, PDO::PARAM_STR); 
                                                $stmt->bindValue(':custId',$_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':cct',1, PDO::PARAM_STR);  
                                                $stmt->bindValue(':bid', $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();
                
                                            }
                                             
                 					    }else if($j1==3)
                                        { 
                                            $CoinVal = ($data['Data']*(0.02))/100;       
                                            $stmt=$conn->prepare("select id from UI__DChstr where Rid=:Rid and typ=1  and status=0 ");   
                                            $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR);   
                                            $stmt->execute();  
                                            if($stmt->rowCount() > 0) 
                                            {
                                                $stmt=$conn->prepare("insert into  UI__Bns (Rid,Brid,Tdate,Tamt,BAmt,level,DaysLeft) values(:Rid,:Brid,:Tdate,:Tamt,:BAmt,:level,:DaysLeft) ");   
                                                $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Brid', $_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tdate', date("d-M-Y") , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tamt', $CoinVal , PDO::PARAM_STR);   
                                                $stmt->bindValue(':BAmt', $data['Data'] , PDO::PARAM_STR);      
                                                $stmt->bindValue(':level', 4  , PDO::PARAM_STR);      
                                                $stmt->bindValue(':DaysLeft', 29  , PDO::PARAM_STR);   
                                                $stmt->execute();   
                                                
                                                $stmt=$conn->prepare("select  * from  UI__Rgst where cuurentId=:cuurentId  ");   
                                                $stmt->bindValue(':cuurentId',  $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();  
                                                $custId = $stmt->fetch(PDO::FETCH_OBJ);
                                                
                                                LvBal($ard[$j1],$CoinVal,1,"Level Balance",$_POST['cuurentId']);  
                                                
                                                $stmt=$conn->prepare("insert into  UI__LevlCt (tblId,custId,cct,bid) values(:tblId,:custId,:cct,:bid) "); 
                                                $stmt->bindValue(':tblId',$DSCId, PDO::PARAM_STR); 
                                                $stmt->bindValue(':custId',$_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':cct',1, PDO::PARAM_STR);  
                                                $stmt->bindValue(':bid', $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();
                
                                            }
                                             
                 					    }else if($j1==4)
                                        { 
                                            $CoinVal = ($data['Data']*(0.01))/100;     
                                            $stmt=$conn->prepare("select id from UI__DChstr where Rid=:Rid and typ=1 and status=0 ");   
                                            $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR);   
                                            $stmt->execute();  
                                            if($stmt->rowCount() > 0) 
                                            {
                                                $stmt=$conn->prepare("insert into  UI__Bns (Rid,Brid,Tdate,Tamt,BAmt,level,DaysLeft) values(:Rid,:Brid,:Tdate,:Tamt,:BAmt,:level,:DaysLeft) ");   
                                                $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Brid', $_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tdate', date("d-M-Y") , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tamt', $CoinVal , PDO::PARAM_STR);   
                                                $stmt->bindValue(':BAmt', $data['Data'] , PDO::PARAM_STR);      
                                                $stmt->bindValue(':level', 5 , PDO::PARAM_STR);      
                                                $stmt->bindValue(':DaysLeft', 29  , PDO::PARAM_STR);   
                                                $stmt->execute();   
                                                
                                                $stmt=$conn->prepare("select  * from  UI__Rgst where cuurentId=:cuurentId  ");   
                                                $stmt->bindValue(':cuurentId',  $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();  
                                                $custId = $stmt->fetch(PDO::FETCH_OBJ);
                                                
                                                LvBal($ard[$j1],$CoinVal,1,"Level Balance",$_POST['cuurentId']);  
                                                
                                                $stmt=$conn->prepare("insert into  UI__LevlCt (tblId,custId,cct,bid) values(:tblId,:custId,:cct,:bid) "); 
                                                $stmt->bindValue(':tblId',$DSCId, PDO::PARAM_STR); 
                                                $stmt->bindValue(':custId',$_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':cct',1, PDO::PARAM_STR);  
                                                $stmt->bindValue(':bid', $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();
                
                                            } 
                 					      }else if($j1==5)
                                        { 
                                            $CoinVal = ($data['Data']*(0.01))/100;     
                                            $stmt=$conn->prepare("select id from UI__DChstr where Rid=:Rid and typ=1 and status=0 ");   
                                            $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR);   
                                            $stmt->execute();  
                                            if($stmt->rowCount() > 0) 
                                            {
                                                $stmt=$conn->prepare("insert into  UI__Bns (Rid,Brid,Tdate,Tamt,BAmt,level,DaysLeft) values(:Rid,:Brid,:Tdate,:Tamt,:BAmt,:level,:DaysLeft) ");   
                                                $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Brid', $_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tdate', date("d-M-Y") , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tamt', $CoinVal , PDO::PARAM_STR);   
                                                $stmt->bindValue(':BAmt', $data['Data'] , PDO::PARAM_STR);      
                                                $stmt->bindValue(':level', 6 , PDO::PARAM_STR);   
                                                $stmt->bindValue(':DaysLeft', 29  , PDO::PARAM_STR);   
                                                $stmt->execute();   
                                                
                                                $stmt=$conn->prepare("select  * from  UI__Rgst where cuurentId=:cuurentId  ");   
                                                $stmt->bindValue(':cuurentId',  $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();  
                                                $custId = $stmt->fetch(PDO::FETCH_OBJ);
                                                
                                                LvBal($ard[$j1],$CoinVal,1,"Level Balance",$_POST['cuurentId']); 
                                                
                                                
                                                $stmt=$conn->prepare("insert into  UI__LevlCt (tblId,custId,cct,bid) values(:tblId,:custId,:cct,:bid) "); 
                                                $stmt->bindValue(':tblId',$DSCId, PDO::PARAM_STR); 
                                                $stmt->bindValue(':custId',$_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':cct',1, PDO::PARAM_STR);  
                                                $stmt->bindValue(':bid', $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();
                
                                            }
                                             
                 					      }else if($j1==6)
                                        { 
                                            $CoinVal = ($data['Data']*(0.01))/100;     
                                            $stmt=$conn->prepare("select id from UI__DChstr where Rid=:Rid and typ=1 and status=0 ");   
                                            $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR);   
                                            $stmt->execute();  
                                            if($stmt->rowCount() > 0) 
                                            {
                                                $stmt=$conn->prepare("insert into  UI__Bns (Rid,Brid,Tdate,Tamt,BAmt,level,DaysLeft) values(:Rid,:Brid,:Tdate,:Tamt,:BAmt,:level,:DaysLeft) ");   
                                                $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Brid', $_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tdate', date("d-M-Y") , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tamt', $CoinVal , PDO::PARAM_STR);   
                                                $stmt->bindValue(':BAmt', $data['Data'] , PDO::PARAM_STR);      
                                                $stmt->bindValue(':level', 7 , PDO::PARAM_STR);        
                                                $stmt->bindValue(':DaysLeft', 29  , PDO::PARAM_STR);   
                                                $stmt->execute();   
                                                
                                                $stmt=$conn->prepare("select  * from  UI__Rgst where cuurentId=:cuurentId  ");   
                                                $stmt->bindValue(':cuurentId',  $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();  
                                                $custId = $stmt->fetch(PDO::FETCH_OBJ);
                                                
                                                 LvBal($ard[$j1],$CoinVal,1,"Level Balance",$_POST['cuurentId']);     
                                                 
                                                
                                                $stmt=$conn->prepare("insert into  UI__LevlCt (tblId,custId,cct,bid) values(:tblId,:custId,:cct,:bid) "); 
                                                $stmt->bindValue(':tblId',$DSCId, PDO::PARAM_STR); 
                                                $stmt->bindValue(':custId',$_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':cct',1, PDO::PARAM_STR);  
                                                $stmt->bindValue(':bid', $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();
                
                                            }
                                             
                 					      }else if($j1==7)
                                        { 
                                            $CoinVal = ($data['Data']*(0.01))/100;     
                                            $stmt=$conn->prepare("select id from UI__DChstr where Rid=:Rid and typ=1 and status=0 ");   
                                            $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR);   
                                            $stmt->execute();  
                                            if($stmt->rowCount() > 0) 
                                            {
                                                $stmt=$conn->prepare("insert into  UI__Bns (Rid,Brid,Tdate,Tamt,BAmt,level,DaysLeft) values(:Rid,:Brid,:Tdate,:Tamt,:BAmt,:level,:DaysLeft) ");   
                                                $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Brid', $_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tdate', date("d-M-Y") , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tamt', $CoinVal , PDO::PARAM_STR);   
                                                $stmt->bindValue(':BAmt', $data['Data'] , PDO::PARAM_STR);      
                                                $stmt->bindValue(':level', 8 , PDO::PARAM_STR);        
                                                $stmt->bindValue(':DaysLeft', 29  , PDO::PARAM_STR);   
                                                $stmt->execute();   
                                                
                                                $stmt=$conn->prepare("select  * from  UI__Rgst where cuurentId=:cuurentId  ");   
                                                $stmt->bindValue(':cuurentId',  $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();  
                                                $custId = $stmt->fetch(PDO::FETCH_OBJ);
                                                
                                                LvBal($ard[$j1],$CoinVal,1,"Level Balance",$_POST['cuurentId']);   
                                                
                                                $stmt=$conn->prepare("insert into  UI__LevlCt (tblId,custId,cct,bid) values(:tblId,:custId,:cct,:bid) "); 
                                                $stmt->bindValue(':tblId',$DSCId, PDO::PARAM_STR); 
                                                $stmt->bindValue(':custId',$_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':cct',1, PDO::PARAM_STR);  
                                                $stmt->bindValue(':bid', $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();
                
                                            }
                                             
                 					      }else if($j1==8)
                                        { 
                                            $CoinVal = ($data['Data']*(0.005))/100;     
                                            $stmt=$conn->prepare("select id from UI__DChstr where Rid=:Rid and typ=1 and status=0 ");   
                                            $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR);   
                                            $stmt->execute();  
                                            if($stmt->rowCount() > 0) 
                                            {
                                                $stmt=$conn->prepare("insert into  UI__Bns (Rid,Brid,Tdate,Tamt,BAmt,level,DaysLeft) values(:Rid,:Brid,:Tdate,:Tamt,:BAmt,:level,:DaysLeft) ");   
                                                $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Brid', $_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tdate', date("d-M-Y") , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tamt', $CoinVal , PDO::PARAM_STR);   
                                                $stmt->bindValue(':BAmt', $data['Data'] , PDO::PARAM_STR);      
                                                $stmt->bindValue(':level', 9 , PDO::PARAM_STR);        
                                                $stmt->bindValue(':DaysLeft', 29  , PDO::PARAM_STR);   
                                                $stmt->execute();   
                                                
                                                $stmt=$conn->prepare("select  * from  UI__Rgst where cuurentId=:cuurentId  ");   
                                                $stmt->bindValue(':cuurentId',  $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();  
                                                $custId = $stmt->fetch(PDO::FETCH_OBJ);
                                                
                                                LvBal($ard[$j1],$CoinVal,1,"Level Balance",$_POST['cuurentId']);  
                                                
                                                $stmt=$conn->prepare("insert into  UI__LevlCt (tblId,custId,cct,bid) values(:tblId,:custId,:cct,:bid) "); 
                                                $stmt->bindValue(':tblId',$DSCId, PDO::PARAM_STR); 
                                                $stmt->bindValue(':custId',$_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':cct',1, PDO::PARAM_STR);  
                                                $stmt->bindValue(':bid', $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();
                                            }
                                             
                 					      }else if($j1==9)
                                        { 
                                            $CoinVal = ($data['Data']*(0.005))/100;     
                                            $stmt=$conn->prepare("select id from UI__DChstr where Rid=:Rid and typ=1 and status=0 ");   
                                            $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR);   
                                            $stmt->execute();  
                                            if($stmt->rowCount() > 0) 
                                            {
                                                $stmt=$conn->prepare("insert into  UI__Bns (Rid,Brid,Tdate,Tamt,BAmt,level,DaysLeft) values(:Rid,:Brid,:Tdate,:Tamt,:BAmt,:level,:DaysLeft) ");   
                                                $stmt->bindValue(':Rid', $ard[$j1] , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Brid', $_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tdate', date("d-M-Y") , PDO::PARAM_STR); 
                                                $stmt->bindValue(':Tamt', $CoinVal , PDO::PARAM_STR);   
                                                $stmt->bindValue(':BAmt', $data['Data'] , PDO::PARAM_STR);      
                                                $stmt->bindValue(':level', 10 , PDO::PARAM_STR);  
                                                $stmt->bindValue(':DaysLeft', 29  , PDO::PARAM_STR);   
                                                $stmt->execute();   
                                                
                                                $stmt=$conn->prepare("select  * from  UI__Rgst where cuurentId=:cuurentId  ");   
                                                $stmt->bindValue(':cuurentId',  $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();  
                                                $custId = $stmt->fetch(PDO::FETCH_OBJ);
                                                
                                                LvBal($ard[$j1],$CoinVal,1,"Level Balance",$_POST['cuurentId']);  
                                                
                                                $stmt=$conn->prepare("insert into  UI__LevlCt (tblId,custId,cct,bid) values(:tblId,:custId,:cct,:bid) "); 
                                                $stmt->bindValue(':tblId',$DSCId, PDO::PARAM_STR); 
                                                $stmt->bindValue(':custId',$_POST['cuurentId'], PDO::PARAM_STR); 
                                                $stmt->bindValue(':cct',1, PDO::PARAM_STR);  
                                                $stmt->bindValue(':bid', $ard[$j1] , PDO::PARAM_STR);   
                                                $stmt->execute();
                                            }
                                             
                 					      }
                 					      
                 					      
                 					        if($stmt->rowCount()>0) 
                 					        {
                 					      
                 					        $stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
                                            $stmt->bindValue(':cuurentId',  $ard[$j1] , PDO::PARAM_STR);  
                                            $stmt->execute();
                                            $UI__Rgst = $stmt->fetch(PDO::FETCH_OBJ);      
                 					       
                                            $stmt=$conn->prepare("insert into UI__Receipt(type,bank,mobile,email,amountPaid,Tid,status,Tdate,custId,cdId,Topay,TopayName) values(:type,:bank,:mobile,:email,:amountPaid,:Tid,:status,:Tdate,:custId,:cdId,:Topay,:TopayName)"); 
                                            $stmt->bindValue(':type',   5 , PDO::PARAM_STR);   
                                            $stmt->bindValue(':bank',  "Level Balance" , PDO::PARAM_STR);   
                                            $stmt->bindValue(':mobile', $UI__Rgst->phm, PDO::PARAM_STR);
                                            $stmt->bindValue(':email', $UI__Rgst->eml , PDO::PARAM_STR); 
                                            $stmt->bindValue(':amountPaid', $CoinVal  , PDO::PARAM_STR); 
                                            $stmt->bindValue(':Tid', mt_rand(1234552,23555), PDO::PARAM_STR); 
                                            $stmt->bindValue(':status', 1 , PDO::PARAM_STR); 
                                            $stmt->bindValue(':Tdate', date("d-M-Y H:i") , PDO::PARAM_STR);      
                                            $stmt->bindValue(':custId', $ard[$j1] , PDO::PARAM_STR);  
                                            $stmt->bindValue(':cdId', $_SESSION['LastIntId']  , PDO::PARAM_STR); 
                                            $stmt->bindValue(':Topay',  $_POST['cuurentId'] , PDO::PARAM_STR); 
                                            $stmt->bindValue(':TopayName',  $_POST['cuurentId'] , PDO::PARAM_STR);     
                                            $stmt->execute();    
                                            unset($_SESSION['LastIntId']); 
                 					        } 
                                       }
                                 }	    
                                
                                $Data = (($data['Data']*5)/100);  
                                $stmt=$conn->prepare("select  refId from UI__Rgst where cuurentId=:cuurentId  "); 
                                $stmt->bindValue(':cuurentId', $_POST['cuurentId']   , PDO::PARAM_STR);  
                                $stmt->execute();  
                                $refId = $stmt->fetch(PDO::FETCH_OBJ);
                                
                                
                                  
                                $stmt=$conn->prepare("select  id from UI__DChstr where Rid=:cuurentId  and typ=1 "); 
                                $stmt->bindValue(':cuurentId',  $refId->refId  , PDO::PARAM_STR);  
                                $stmt->execute();  
                                if($stmt->rowCount() > 0)    
                				{
                				
                                 
                                $stmt=$conn->prepare("insert into  UI__Tpm (TopUpId,Amt,Tdate,RefTbl,custId) values(:TopUpId,:Amt,:Tdate,:RefTbl,:custId)"); 
                                $stmt->bindValue(':TopUpId', $refId->refId , PDO::PARAM_STR); 
                                $stmt->bindValue(':Amt', $Data , PDO::PARAM_STR); 
                                $stmt->bindValue(':Tdate', date("d-M-Y") , PDO::PARAM_STR);  
                                $stmt->bindValue(':RefTbl', $_POST['cuurentId'] , PDO::PARAM_STR);  
                                $stmt->bindValue(':custId', $_POST['cuurentId'] , PDO::PARAM_STR);    
                                $stmt->execute();   
                                  
                                LvBal($refId->refId,$Data,1,"Spot Balance",$_POST['cuurentId']);     
                                
                                $stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
                                $stmt->bindValue(':cuurentId',  $refId->refId , PDO::PARAM_STR);  
                                $stmt->execute();
                                $UI__Rgst = $stmt->fetch(PDO::FETCH_OBJ);     	 
                
                                $stmt=$conn->prepare("insert into UI__Receipt(type,bank,mobile,email,amountPaid,Tid,status,Tdate,custId,cdId,Topay,TopayName) values(:type,:bank,:mobile,:email,:amountPaid,:Tid,:status,:Tdate,:custId,:cdId,:Topay,:TopayName)"); 
                                $stmt->bindValue(':type',   4 , PDO::PARAM_STR);   
                                $stmt->bindValue(':bank',  "Spot Balance" , PDO::PARAM_STR);   
                                $stmt->bindValue(':mobile', $UI__Rgst->phm, PDO::PARAM_STR);
                                $stmt->bindValue(':email', $UI__Rgst->eml , PDO::PARAM_STR); 
                                $stmt->bindValue(':amountPaid', $Data  , PDO::PARAM_STR); 
                                $stmt->bindValue(':Tid', mt_rand(1234552,23555), PDO::PARAM_STR); 
                                $stmt->bindValue(':status', 1 , PDO::PARAM_STR); 
                                $stmt->bindValue(':Tdate', date("d-M-Y H:i") , PDO::PARAM_STR);      
                                $stmt->bindValue(':custId', $_POST['cuurentId'], PDO::PARAM_STR);  
                                $stmt->bindValue(':cdId', $_SESSION['LastIntId']  , PDO::PARAM_STR); 
                                $stmt->bindValue(':Topay',  $refId->refId  , PDO::PARAM_STR); 
                                $stmt->bindValue(':TopayName',  $refId->refId , PDO::PARAM_STR);     
                                $stmt->execute();    
                                unset($_SESSION['LastIntId']);
                                
                
                				}
                            
                            $Tdt = date("d-M-Y", strtotime($dmt->Tdate));   
                            $amount = number_format((float)(($data['Data']*2)/400), 2, '.', '');
                            $stmt=$conn->prepare("insert into UI__DailyROIGene(custId,amount,Tdate,TopUpdate) values(:custId,:amount,:Tdate,:TopUpdate)"); 
                            $stmt->bindValue(':custId',  $_POST['cuurentId'] , PDO::PARAM_INT);   
                            $stmt->bindValue(':amount', $amount , PDO::PARAM_INT);    
                            $stmt->bindValue(':Tdate',  date("d-M-Y") , PDO::PARAM_STR);   
                            $stmt->bindValue(':TopUpdate',  date("d-M-Y") , PDO::PARAM_STR);      
                            $stmt->execute();   
                            LvBal($_POST['cuurentId'],$amount,1,"Daily Balanace","NA");  
                                
                            
                            $stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
                            $stmt->bindValue(':cuurentId',  $_POST['cuurentId'] , PDO::PARAM_STR);  
                            $stmt->execute();
                            $UI__Rgst = $stmt->fetch(PDO::FETCH_OBJ);     	
                            
            
                            $stmt=$conn->prepare("insert into UI__Receipt(type,bank,mobile,email,amountPaid,Tid,status,Tdate,custId,cdId,Topay,TopayName) values(:type,:bank,:mobile,:email,:amountPaid,:Tid,:status,:Tdate,:custId,:cdId,:Topay,:TopayName)"); 
                            $stmt->bindValue(':type',   3 , PDO::PARAM_STR);   
                            $stmt->bindValue(':bank',  "Daily Balance" , PDO::PARAM_STR);   
                            $stmt->bindValue(':mobile', $UI__Rgst->phm, PDO::PARAM_STR);
                            $stmt->bindValue(':email', $UI__Rgst->eml , PDO::PARAM_STR); 
                            $stmt->bindValue(':amountPaid', $amount  , PDO::PARAM_STR); 
                            $stmt->bindValue(':Tid', mt_rand(1234552,23555), PDO::PARAM_STR); 
                            $stmt->bindValue(':status', 1 , PDO::PARAM_STR); 
                            $stmt->bindValue(':Tdate', date("d-M-Y H:i") , PDO::PARAM_STR);      
                            $stmt->bindValue(':custId', $_POST['cuurentId'] , PDO::PARAM_STR);  
                            $stmt->bindValue(':cdId', $_SESSION['LastIntId']  , PDO::PARAM_STR); 
                            $stmt->bindValue(':Topay',  "NA" , PDO::PARAM_STR); 
                            $stmt->bindValue(':TopayName',  "NA"  , PDO::PARAM_STR);     
                            $stmt->execute();    
                            unset($_SESSION['LastIntId']);
                                
                            $stmt=$conn->prepare("insert into UI__TopWithDrw(custId,Tdate,status,type,amt) values(:custId,:Tdate,:status,:type,:amt)"); 
                            $stmt->bindValue(':custId',  $_POST['cuurentId'] , PDO::PARAM_STR);   
                            $stmt->bindValue(':Tdate',  date("d-M-Y") , PDO::PARAM_STR);   
                            $stmt->bindValue(':status', 0 , PDO::PARAM_INT);     
                            $stmt->bindValue(':type',  1 , PDO::PARAM_INT);
                            $stmt->bindValue(':amt', $data['Data'] , PDO::PARAM_STR);
                            $stmt->execute();      
                            
                            
                            $stmt=$conn->prepare("select eml from UI__Rgst  where  cuurentId=:cuurentId    ");   
                            $stmt->bindValue(':cuurentId',  $_SESSIONuserId , PDO::PARAM_STR);  
                            $stmt->execute(); 
                            $EMAIL = $stmt->fetch(PDO::FETCH_OBJ);    
                            
                
                                    
                                    $subject = "Top Up  On ".$SITE_NAME;  
                                    $template_type = 1;
                                    $attachment = '';
                                    $name = $_POST['cuurentId'];
                                    $Amt = $data['Data'];
                                    
                                    $message="
                                    <tr>
                                    <td align='left' valign='top'>
                                    <h4 style='font-weight:bold; padding:2px 2px; margin:3px; text-align:left; color:#002368;'>Dear user,</h4>
                                    <h5 style='font-weight:bold; padding:2px 2px; margin:0px; text-align:center; color:#002368;'>Thanks for Wallet Transfer with us. Your Details are as follows </h5> 
                                    <h5 style='font-weight:bold; padding:2px 2px; margin:0px; text-align:center; color:#002368;'> To: $name , Amount Rs : $Amt </h5>
                                    
                                    </td>
                                    </tr>"; 
                                    
                               // SendMail($EMAIL->eml,$subject,$message,$template_type,$attachment);      
                            }    
                    }else
                    { 
                        
                    $_POST['userid'] = $AllUsers->custId;    
                    
                    $_POST['fund']  = ($AllUsers->AMMT*87);
                    $stmt=$conn->prepare("select  amt,availableFund from  UI__Fundtransfer   where userid=:cuurentId order by id desc");  
                    $stmt->bindValue(':cuurentId', $_POST['userid'] , PDO::PARAM_STR);
                    $stmt->execute();  
                    
                    if($stmt->rowCount() > 0)
                    {
                       $AllUsers = $stmt->fetch(PDO::FETCH_OBJ); 
                       $totalAvaib = $AllUsers->availableFund+$_POST['fund'];  
                    }else
                        $totalAvaib =  $_POST['fund'];     
                     
        			$stmt=$conn->prepare("insert into  UI__Fundtransfer (userid,Tdate,amt,availableFund) values(:userid,:Tdate,:amt,:availableFund)    "); 
                    $stmt->bindValue(':userid',$_POST['userid'], PDO::PARAM_STR); 
                    $stmt->bindValue(':Tdate',date("d-M-Y H:i"), PDO::PARAM_STR); 
                    $stmt->bindValue(':amt',$_POST['fund'], PDO::PARAM_STR);  
                    $stmt->bindValue(':availableFund', $totalAvaib , PDO::PARAM_STR);  
                    $stmt->execute(); 
                     
                    
                    $stmt=$conn->prepare("select *  from UI__DailyROIGene    where custId=:sId     ");   
                    $stmt->bindValue(':sId',  $_POST['userid'] , PDO::PARAM_INT);  
                    $stmt->execute(); 
                    $XUI__DailyROIGene = $stmt->fetchAll(PDO::FETCH_OBJ);  
                    
                    $Tamnt = 0;
                    foreach($XUI__DailyROIGene as $xx)
                    {
                    $Tamnt +=$xx->amount;
                    }      
                    
                    
                    $stmt=$conn->prepare("select *  from UI__Bns    where Rid =:sId   ");   
                    $stmt->bindValue(':sId',  $_POST['userid'] , PDO::PARAM_INT);  
                    $stmt->execute(); 
                    $UI__Bns = $stmt->fetchAll(PDO::FETCH_OBJ); 
                    
                    $LevelI = 0;
                    foreach($UI__Bns as $dddm)
                    {
                    $LevelI +=$dddm->Tamt;
                    }
                    
                    
                    $stmt=$conn->prepare("select Amt   from UI__Tpm where TopUpId=:refId   ");   
                    $stmt->bindValue(':refId',  $_POST['userid'] , PDO::PARAM_INT);  
                    $stmt->execute(); 
                    $MdirectB = $stmt->fetchAll(PDO::FETCH_OBJ);  
                    
                    $directIncome = 0;
                    foreach($MdirectB as $dmm)
                    $directIncome += $dmm->Amt;                
                    
                    
                    
                    
                    $stmt=$conn->prepare("select *  from UI__WithDraw    where userid=:sId and (accept=1 ||accept=2)  ");   
                    $stmt->bindValue(':sId', $_POST['userid'] , PDO::PARAM_INT);  
                    $stmt->execute(); 
                    $UI__WithDraw = $stmt->fetchAll(PDO::FETCH_OBJ); 
                    
                    
                    $totalWithdrwa = 0;
                    foreach($UI__WithDraw as $tl)
                    {
                    $totalWithdrwa +=$tl->amt;
                    }
                    
                      
                    $stmt=$conn->prepare("select availableFund from UI__Fundtransfer  where  userid=:userid  order by id desc  ");   
                    $stmt->bindValue(':userid',  $_POST['userid'] , PDO::PARAM_INT);  
                    $stmt->execute(); 
                    $UI__Fundtransfer = $stmt->fetch(PDO::FETCH_OBJ);   
                    
                       
                    $PAYWAllet =  ($Tamnt+$LevelI+$directIncome+$UI__Fundtransfer->availableFund)-($totalWithdrwa);      
                    $stmt=$conn->prepare("insert into  UI__DebitCredit (custId,addDel,availableBal,Tdate,type,Intype,byw) values(:custId,:addDel,:availableBal,:Tdate,:type,'Fund Credited By User','NA')"); 
                    $stmt->bindValue(':custId',$_POST['userid'], PDO::PARAM_STR); 
                    $stmt->bindValue(':addDel',$_POST['fund'], PDO::PARAM_STR); 
                    $stmt->bindValue(':availableBal',$PAYWAllet, PDO::PARAM_STR);  
                    $stmt->bindValue(':Tdate', date("d-M-Y H:i") , PDO::PARAM_STR);  
                    $stmt->bindValue(':type', 1 , PDO::PARAM_STR);   
                    $stmt->execute();     
                    
                    $stmt=$conn->prepare("select id from UI__Rgst  where  cuurentId=:cuurentId    ");   
                    $stmt->bindValue(':cuurentId',  $_POST['userid'] , PDO::PARAM_STR);  
                    $stmt->execute(); 
                    $UIid = $stmt->fetch(PDO::FETCH_OBJ);   
                    
                    $amount = password_hash(($PAYWAllet),PASSWORD_DEFAULT);  
                    $stmt =  $conn->prepare("update _pkCc__ set bl1=:bl1,tm=:tm where Uxd=:Uxd "); 
                    $stmt->bindValue(':bl1', $amount, PDO::PARAM_STR); 
                    $stmt->bindValue(':tm', date("d-M-Y H:i"), PDO::PARAM_STR); 
                    $stmt->bindValue(':Uxd', $UIid->id, PDO::PARAM_STR);  
                    $stmt->execute();       
                    }   
                        
                    $stmt=$conn->prepare("update  UI__USDTRest  set note=:note , status=:status  where id=:id ");  
                    $stmt->bindValue(':note', $_POST['noteDt'] , PDO::PARAM_STR);
                    $stmt->bindValue(':status', $_POST['Status'] , PDO::PARAM_STR);
                    $stmt->bindValue(':id', $_REQUEST['id'] , PDO::PARAM_STR); 
                    $stmt->execute();  
                }   

                header("Location: USDTedit.php");
                die;
            }     
                        
            $stmt=$conn->prepare("select  * from   UI__USDTRest where id=:id ");  
            $stmt->bindValue(':id', $_REQUEST['id'] , PDO::PARAM_STR);
            $stmt->execute(); 
            $AllUsers = $stmt->fetch(PDO::FETCH_OBJ); 
?>  
<?php  include ABS_PATH.'/admin/header.php';	?>  

<script>
function del_record(val)
{

	var r = confirm("Do you really want to delete record !");
	if (r == true) {    
	$.ajax({
	type: 'POST',
	url: "../ajax/default.php",
	//async: false,			 
	data: {del_city_names: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>update Request    </h3></div>
					
					<div align="right">  <input type="button"    class="btn btn-warning" name="btnback" id="btnback" value=" Back " onClick="javascript:location.href='UsdtwalletRst.php';" />
					</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>CustId</th> 
								<th>Name</th>  	  
								<th>Amount</th>  
								<th>Type</th> 
								<th>Address</th>  
							</tr>
						</thead>
						<tbody>
							<?php 
                                    $stmt=$conn->prepare("select  * from   UI__USDTRest  where id=:id");    
                                    $stmt->bindValue(':id', $_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=:custId ");  
                                    $stmt->bindValue(':custId', $users->custId , PDO::PARAM_STR);
                                    $stmt->execute();   
                                    $userName = $stmt->fetch(PDO::FETCH_OBJ); 

							?>
							<tr class="odd gradeX">
								<td><?php echo $sr++;?> </td>
								<td><?php echo $users->custId;?></td>
								<td><?php echo $userName->nm;?></td>
								<td><?php echo  $users->AMMT ;?>  </td> 
								<td><?php   if($users->PgTYpe==1) echo "TopUp";else echo "Withdrawl"; ?>  </td> 
								<td><?php   echo $users->address; ?>  </td>   
							</tr>  
							<?php } ?>
						</tbody>
					</table>
					
					
					
					   <?php 
					    if($AllUsers->status==0) {
					   ?> 
					    <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" id="product_frm" autocomplete="off"> 
								 
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Status</label>
								    <div class="col-sm-3">
								     <select  class="form-control" name="Status">
								         <option value="1" <?php if($AllUsers->status==1) echo "selected"; ?>>Approved</option>
								         <option value="0" <?php if($AllUsers->status==0) echo "selected"; ?>>Pending</option>
								         <option value="2" <?php if($AllUsers->status==2) echo "selected"; ?>>Rejected</option>
								     </select>
								    </div>
								 </div>
								 <hr>
								 
							 	 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Note</label>
								    <div class="col-sm-3">
								      <input type="text" name="noteDt"  class="form-control" value="NA"/>
								    </div>
								 </div>
								 <hr>
								  
								  
								  <div class="form-group">
										<label for="inputEmail3" class="col-sm-2 control-label">Update</label>
										<div class="col-sm-10">
										  <input type="submit"    class="btn btn-primary"  name="update" value="Update Status">
										</div>
								  </div>   
								</form>
					<?php } ?>			
								
								
  				</div>
  			</div>



		  </div>
		</div>
    </div>

<?php  include ABS_PATH.'/admin/footer.php';	?>    