<?php
	include_once('../config.php');    
	include_once(ABS_PATH.'/custom_function/default.php');  
	       
 
            $set = 0;
            if(date("H:i")=="01:30")
            $set = 1;     
 							
            
                
  
  
                $stmt=$conn->prepare("insert test   (name) values(:Rname) ");   
                $stmt->bindValue(':Rname', "syp1..".date("d-M-Y H:i") , PDO::PARAM_STR);  
                $stmt->execute();  
                

	            if(($_REQUEST['Ffnvwvbv']=='NEUIEUBNDDOUIOEIONKLV6897634fnfvBVKV34') && ($set==1)) 
	           { 
	               
	               
      
                    $stmt=$conn->prepare("insert test   (name) values(:Rname) ");   
                    $stmt->bindValue(':Rname', "syp2..".date("d-M-Y H:i") , PDO::PARAM_STR);  
                    $stmt->execute();  
                    
								       
                    $stmt=$conn->prepare("select  *   from  UI__DChstr where typ=1  and Rid!='DP112233' and specialUser=0 and Rid='DP841053' ");   
                    $stmt->execute();  
                    $UI__DailyROIGeneCt = $stmt->fetchAll(PDO::FETCH_OBJ);  
                   // echo '<pre>'; print_r($UI__DailyROIGeneCt); die; 
                    
                    
                    foreach($UI__DailyROIGeneCt as $dmt)
                    {      
						
						$stmt=$conn->prepare("select   is_active,id  from  UI__Rgst where  cuurentId=:cuurentId   ");
						$stmt->bindValue(':cuurentId', $dmt->Rid , PDO::PARAM_STR);   								
						$stmt->execute();  
						$is_active = $stmt->fetch(PDO::FETCH_OBJ); 
						$MyctId = $is_active->id; 
						 
								$stmt=$conn->prepare(" select phm  from  UI__Rgst where  cuurentId=:cuurentId   ");
								$stmt->bindValue(':cuurentId', $dmt->Rid , PDO::PARAM_STR);   								
								$stmt->execute();  
								$phm = $stmt->fetch(PDO::FETCH_OBJ);     

                                  
                                $originalDate = $dmt->Tdate;
                                $OldD = date("d-m-Y", strtotime($originalDate)); 
                                //$OldD = date("d-m-Y", strtotime($originalDate. ' -1 day')); 
                                
                                $newDate = date("d-m-Y");
                                $date1 = new DateTime($OldD);
                                $date2 = new DateTime($newDate);
                                $interval = $date1->diff($date2);  
                                
                                  
                                if($interval->d <=$dmt->dys)
                                {     	
										$Tdt = date("d-M-Y", strtotime($dmt->Tdate));   
                                        $amount = ($dmt->amt*2)/$dmt->dys;   
                                        $amount = number_format((float)$amount, 2, '.', '');
                                        
                                        $stmt=$conn->prepare("select   id  from  UI__Rgst where  cuurentId=:cuurentId   ");
                                        $stmt->bindValue(':cuurentId', $dmt->Rid , PDO::PARAM_STR);   								
                                        $stmt->execute();  
                                        $is_activeXX = $stmt->fetch(PDO::FETCH_OBJ); 

                                       
										{ 
                                        
                                        $stmt=$conn->prepare("insert into UI__DailyROIGeneForD(custId,amount,Tdate,TopUpdate) values(:custId,:amount,:Tdate,:TopUpdate)"); 
                                        $stmt->bindValue(':custId', $dmt->Rid , PDO::PARAM_INT);   
                                        $stmt->bindValue(':amount', $amount , PDO::PARAM_INT);    
                                        $stmt->bindValue(':Tdate',  date("d-M-Y") , PDO::PARAM_STR);   
                                        $stmt->bindValue(':TopUpdate',  $Tdt , PDO::PARAM_STR);      
                                        $stmt->execute();  
                                        
                                                                      
                                                                     
                                        $stmt=$conn->prepare("select *   from   UI__DebitCreditForD order by Id desc   ");   
                                        $stmt->bindValue(':userid',  $dmt->Rid , PDO::PARAM_INT);  
                                        $stmt->execute(); 
                                        $UI__DebitCreditForD = $stmt->fetch(PDO::FETCH_OBJ);   
                                        $availableBal = $amount+$UI__DebitCreditForD->availableBal;                                   
                    				
                                        $stmt=$conn->prepare("insert into  UI__DebitCreditForD (custId,addDel,availableBal,Tdate,type,Intype) values(:custId,:addDel,:availableBal,:Tdate,:type,'Daily Balance')    "); 
                                        $stmt->bindValue(':custId',$dmt->Rid, PDO::PARAM_STR); 
                                        $stmt->bindValue(':addDel',$amount, PDO::PARAM_STR); 
                                        $stmt->bindValue(':availableBal', $availableBal, PDO::PARAM_STR);  
                                        $stmt->bindValue(':Tdate', date("d-M-Y H:i") , PDO::PARAM_STR);  
                                        $stmt->bindValue(':type', 1 , PDO::PARAM_STR);  
                                        $stmt->execute();    
                                      }    
                                }    
                       
					}// for end  
        		 
	            }     