<?php
	include_once('../config.php');    
   
                
                    
                    $set = 0;
                    if(date("H:i")=="06:00")
                    $set = 1;    
                 
                
                    if(($_REQUEST['Ffnvwvbv']=='NEUIEUBNDDOUIOEIONKLV6897634fnfvBVKV34') && ($set==1)) 
                    { 
                    				       
                        $stmt=$conn->prepare("select  *   from   UI__ConirmQr where trasnferStatus = 0 and tranfredDate=''  group by custId");   
                        $stmt->execute();  
                        $UI__DailyROIGeneCt = $stmt->fetchAll(PDO::FETCH_OBJ);  
                         
                         
                        $yestDay = date('d-M-Y', strtotime('-1 day', strtotime(date("d-M-Y")))); 
                        foreach($UI__DailyROIGeneCt as $mpp)
                        {
                            
                            $stmt=$conn->prepare("select  *   from   UI__ConirmQr where custId=:custId and  trasnferStatus = 0 and tranfredDate='' ");   
                            $stmt->bindValue(':custId',  $mpp->custId , PDO::PARAM_STR);   
                            $stmt->execute();  
                            $UI__ConirmQr = $stmt->fetchAll(PDO::FETCH_OBJ); 
                            
                            $amt = 0;
                            foreach($UI__ConirmQr as $mp)
                                 $amt +=$mp->Amt; 
                            
                            
                            $stmt=$conn->prepare("select  *   from   UI__CollTopup where custId=:custId and Tdate=:Tdate ");   
                            $stmt->bindValue(':custId',  $mpp->custId , PDO::PARAM_STR);   
                            $stmt->bindValue(':Tdate', $yestDay , PDO::PARAM_STR);   
                            $stmt->execute();  
                            $UI__CollTopup = $stmt->fetchAll(PDO::FETCH_OBJ); 
                            
                            $camt =0;
                            foreach($UI__CollTopup as $mp)
                                 $camt +=$mp->Amt; 
                                  
                             
                            AddFundNew($mpp->custId,($amt-$camt),"Collection QR Transfered");  
                            
                            
                            $stmt=$conn->prepare("update   UI__ConirmQr  set tranfredDate=:tranfredDate ,trasnferStatus = 1 where  custId=:custId  ");   
                            $stmt->bindValue(':tranfredDate',  date("d-M-Y") , PDO::PARAM_STR);   
                            $stmt->bindValue(':custId',  $mpp->custId , PDO::PARAM_STR);   
                            $stmt->execute(); 
                            
                            
                            $stmt=$conn->prepare("insert into  UI__ConirmQr(custId,Tdate,Amt,tranfredDate,trasnferStatus,type,sender_vpa,sender_name,balance) values(:custId,:Tdate,:Amt,:tranfredDate,1,1,'NA',:sender_name,0)"); 
                            $stmt->bindValue(':custId',    $mpp->custId , PDO::PARAM_STR);   
                            $stmt->bindValue(':Tdate',   date("d-M-Y") , PDO::PARAM_STR);   
                            $stmt->bindValue(':Amt',   ($amt-$camt) , PDO::PARAM_STR); 
                            $stmt->bindValue(':tranfredDate',   date("d-M-Y H:i") , PDO::PARAM_STR);  
                            $stmt->bindValue(':sender_name',   "Auto transfered to main balance" , PDO::PARAM_STR);    
                            $stmt->execute(); 
                           
                        }   
                
                    }
                    