<?php
	include_once('../config.php');    
	include_once(ABS_PATH.'/custom_function/default.php');  
	        
	         
	                            
	                                     
	                                 
 
            $set = 0;
            if(date("H:i")=="00:30")
            $set = 1;     
 							
           function sendMl($eml,$amount)
           {
                $subject = "Level income generated on ".$SITE_NAME;  
                $template_type = 1;
                $attachment = '';  
                $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;'>Your daily income generated. Details are as follows </h5> 
                <h5 style='font-weight:bold; padding:2px 2px; margin:0px; text-align:center; color:#002368;'>Amount: $amount   </h5>
                
                </td>
                </tr>";   
                SendMail($Str->eml,$subject,$message,$template_type,$attachment);  
               
           }
                
                
                function Insetdata($dmtRid,$amount,$Tdt)
				{ 	
				
					global $conn;
					$stmt=$conn->prepare("insert into UI__DailyROIGene(custId,amount,Tdate,TopUpdate) values(:custId,:amount,:Tdate,:TopUpdate)"); 
					$stmt->bindValue(':custId', $dmtRid , 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 eml from UI__Rgst where cuurentId =:cuurentId ");   
					$stmt->bindValue(':cuurentId', $dmtRid, PDO::PARAM_STR);  
					$stmt->execute();  
					$Str = $stmt->fetch(PDO::FETCH_OBJ); 
					
					/// 
														
					$stmt=$conn->prepare("select *  from UI__DailyROIGene    where custId=:sId     ");   
					$stmt->bindValue(':sId', $dmtRid , 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 Tamt  from UI__Bns    where Rid =:sId   ");   
						$stmt->bindValue(':sId',  $dmtRid , 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',  $dmtRid , 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',  $dmtRid, 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',  $dmtRid , PDO::PARAM_INT);  
					$stmt->execute(); 
					$UI__Fundtransfer = $stmt->fetch(PDO::FETCH_OBJ); 
					
					 
							
					$stmt=$conn->prepare("select nm  from UI__Rgst    where cuurentId=:cuurentId     ");   
					$stmt->bindValue(':cuurentId',  $dmtRid , PDO::PARAM_INT);  
					$stmt->execute(); 
					$UI__nm = $stmt->fetch(PDO::FETCH_OBJ);     
					$BY = $UI__nm->nm;
					
					$PAYWAllet =  ($Tamnt+$LevelI+$directIncome+$UI__Fundtransfer->availableFund)-($totalWithdrwa);        
					 
				
					$stmt=$conn->prepare("insert into  UI__DebitCredit (custId,addDel,availableBal,Tdate,type,Intype) values(:custId,:addDel,:availableBal,:Tdate,:type,'Daily Balance')    "); 
					$stmt->bindValue(':custId',$dmtRid, PDO::PARAM_STR); 
					$stmt->bindValue(':addDel',$amount, 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(); 
				}
  
	          // if(($_REQUEST['Ffnvwvbv']=='NEUIEUBNDDOUIOEIONKLV6897634fnfvBVKV34') && ($set==1)) 
	           { 
                    $stmt=$conn->prepare("select  cuurentId from  UI__Rgst  order by id");   
                    $stmt->execute(); 
                    $Repoints = $stmt->fetchAll(PDO::FETCH_OBJ); 
                    $sr = 1; 
								       
                    $stmt=$conn->prepare("select  *   from  UI__DChstr where typ=1  and Rid='DP916253'   and specialUser=0 and status=0 ");   
                    $stmt->execute();  
                    $UI__DailyROIGeneCt = $stmt->fetchAll(PDO::FETCH_OBJ);  
 
 
                    foreach($UI__DailyROIGeneCt as $rdp)
                    {    
						$stmt=$conn->prepare("update   UI__Rgst set rewardPoints=:rewardPoints   where  cuurentId=:cuurentId   ");
						$stmt->bindValue(':rewardPoints',  rand (0, 10) , PDO::PARAM_STR);  
						$stmt->bindValue(':cuurentId', $rdp->Rid , PDO::PARAM_STR);  
						//$stmt->execute(); 
                    }  
                    
                    echo '<pre>'; print_r($UI__DailyROIGeneCt);
                   
                     
                    
                    foreach($UI__DailyROIGeneCt as $dmt)
                    {      
						
						$stmt=$conn->prepare("select   is_active,id,DPthough  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; 
							
                        //if($is_active->is_active==1)
						{
								$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);     

                                    
                                $abb[] = $dmt->Rid;  
                                if(in_array($dmt->Rid,$abb ) )
                                {
                                 
                                    ///
                                    
                                }else
                                {
                                    
    								$cuurentId =  $dmt->Rid;
    								$mob = $phm->phm;
    								$msg = urlencode('Dear '.$cuurentId.', your payout has been credited in DP account. DailyPay team.'); 
    								$URL  = 'http://mobicomm.dove-sms.com//submitsms.jsp?user=DailyPAY&key=d92eabc025XX&mobile=+91'.$mob.'&message='.$msg.'&senderid=DAYPAY&accusage=1&entityid=1201169824017740929&tempid=1207169883670529224';
    								 
    
    							 
                                }
                                
                                $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->days < $dmt->dys)
                                {     	
                                    
                                      
										$Tdt = date("d-M-Y", strtotime($dmt->Tdate));   
										
                                        if( ($dmt->Rid=="DP465420") || ($dmt->Rid=="DP113620") ) 
                                        {
                                            $amount = ($dmt->amt*1.5)/$dmt->dys;   
                                            $amount = number_format((float)$amount, 2, '.', ''); 
                                            $Tamount = ($dmt->amt*0.5)/$dmt->dys;
                                            Insetdata("DP628557",$Tamount,$Tdt);    
                                        }else
                                        {  
                                           
                                            if($dmt->grabDays==1)
												$amount = ($dmt->amt)/100;
											else
											{	
												$amount = ($dmt->amt*2)/$dmt->dys;   
												$amount = number_format((float)$amount, 2, '.', '');
											} 
                                             
                                        }
                                        $stmt=$conn->prepare("select   id,allDysroi,grabPlans  from  UI__Rgst where  cuurentId=:cuurentId   ");
                                        $stmt->bindValue(':cuurentId', $dmt->Rid , PDO::PARAM_STR);   								
                                        $stmt->execute();  
                                        $is_activeXX = $stmt->fetch(PDO::FETCH_OBJ); 
                                        
                                        if($dmt->ManualAmt!=0)
									    {   
									            if($ManualSet->ManualSet>0)
												    $amount = $dmt->ManualAmt;
									    
                                            								        
									    }
									    
									    
									    die;
									    
									
										if($is_activeXX->grabPlans==1)
										{
											if($is_active->DPthough==0)
											{ 	 
												$stmt=$conn->prepare("select   id  from  UI__DailyROIGeneClone  where  UI__DChstrId=:UI__DChstrId   ");
												$stmt->bindValue('UI__DChstrId', $dmt->id , PDO::PARAM_STR);   								
												$stmt->execute();  
												if($stmt->rowCount()>100)  
												{
													$amount = ($dmt->amt)/300;
													$amount = number_format((float)$amount, 2, '.', '');
													
												}else
												{
													$amount = ($dmt->amt)/100;
													$amount = number_format((float)$amount, 2, '.', '');
												} 
												
											}else
											{
												
												$stmt=$conn->prepare("select   id  from   UI__DailyROIGene  where  UI__DChstrId=:UI__DChstrId   ");
												$stmt->bindValue('UI__DChstrId', $dmt->id , PDO::PARAM_STR);   								
												$stmt->execute();  
												if($stmt->rowCount()>100)  
												{
													$amount = ($dmt->amt)/300;
													$amount = number_format((float)$amount, 2, '.', '');
													
												}else
												{
													$amount = ($dmt->amt)/100;
													$amount = number_format((float)$amount, 2, '.', '');
												} 
											}   
										} 


                                        $stmt=$conn->prepare("select   ManualSet  from    UI__DChstr  where  id=:id   ");
                                        $stmt->bindValue('id', $dmt->id , PDO::PARAM_STR);   								
                                        $stmt->execute();  
                                        $ManualSet = $stmt->fetch(PDO::FETCH_OBJ); 
												
                                        if( ($is_activeXX->id < 877) || ($is_activeXX->allDysroi==1) )
										{     
										    
										    if($dmt->ManualAmt!=0)
										    {   
										            if($ManualSet->ManualSet>0)
													    $amount = $dmt->ManualAmt;
										    }else
										    {
                                                $MPset = $ManualSet->ManualSet -1;  
                                                $stmt=$conn->prepare("update   UI__DChstr set  ManualSet=:ManualSet where  id=:id   ");
                                                $stmt->bindValue('ManualSet', $MPset , PDO::PARAM_STR);  
                                                $stmt->bindValue('id', $dmt->id , PDO::PARAM_STR);  
                                                $stmt->execute();  
										    }
                                        
											if($is_active->DPthough==0)
											{
												
												$stmt=$conn->prepare("insert into UI__DailyROIGeneClone(custId,amount,Tdate,TopUpdate,UI__DChstrId) values(:custId,:amount,:Tdate,:TopUpdate,:UI__DChstrId)"); 
												$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->bindValue(':UI__DChstrId',  $dmt->id , PDO::PARAM_STR);      
												$stmt->execute(); 
											}
										else 
										{ 	 
														//
												$stmt=$conn->prepare("insert into UI__DailyROIGene(custId,amount,Tdate,TopUpdate,UI__DChstrId) values(:custId,:amount,:Tdate,:TopUpdate,:UI__DChstrId)"); 
												$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->bindValue(':UI__DChstrId',  $dmt->id , PDO::PARAM_STR);      
												$stmt->execute();  
												
												$stmt=$conn->prepare("select eml from UI__Rgst where cuurentId =:cuurentId ");   
												$stmt->bindValue(':cuurentId', $dmt->Rid, PDO::PARAM_STR);  
												$stmt->execute();  
												$Str = $stmt->fetch(PDO::FETCH_OBJ); 
												
												/// 
																					
												$stmt=$conn->prepare("select  amount  from UI__DailyROIGene    where custId=:sId     ");   
												$stmt->bindValue(':sId', $dmt->Rid , 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 Tamt  from UI__Bns    where Rid =:sId   ");   
													$stmt->bindValue(':sId',  $dmt->Rid , 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',  $dmt->Rid , PDO::PARAM_INT);  
														$stmt->execute(); 
														$MdirectB = $stmt->fetchAll(PDO::FETCH_OBJ);  
														
														$directIncome = 0;
														foreach($MdirectB as $dmm)
															$directIncome += $dmm->Amt;                
													
													
												
												
												$stmt=$conn->prepare("select amt  from UI__WithDraw    where userid=:sId and (accept=1 ||accept=2)  ");   
												$stmt->bindValue(':sId',  $dmt->Rid, 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',  $dmt->Rid , PDO::PARAM_INT);  
												$stmt->execute(); 
												$UI__Fundtransfer = $stmt->fetch(PDO::FETCH_OBJ); 
												
												 
														
												$stmt=$conn->prepare("select nm  from UI__Rgst    where cuurentId=:cuurentId     ");   
												$stmt->bindValue(':cuurentId',  $dmt->Rid , PDO::PARAM_INT);  
												$stmt->execute(); 
												$UI__nm = $stmt->fetch(PDO::FETCH_OBJ);     
												$BY = $UI__nm->nm;
												
												$PAYWAllet =  ($Tamnt+$LevelI+$directIncome+$UI__Fundtransfer->availableFund)-($totalWithdrwa);        
												 
											
												$stmt=$conn->prepare("insert into  UI__DebitCredit (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',($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();
												$_SESSION['LastIntId'] = $conn->lastInsertId();;
												
												$stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
												$stmt->bindValue(':cuurentId',  $dmt->Rid , PDO::PARAM_STR);  
												$stmt->execute();
												$UI__Rgst = $stmt->fetch(PDO::FETCH_OBJ);   
												unset($_SESSION['LastIntId']);	
												
										} 
										
                            			$subject = "Daily income generated on ".$SITE_NAME;  
                            			$template_type = 1;
                            			$attachment = '';  
                            			$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;'>Your daily income generated. Details are as follows </h5> 
                            			<h5 style='font-weight:bold; padding:2px 2px; margin:0px; text-align:center; color:#002368;'>Amount: $amount   </h5>
                            
                            			</td>
                            			</tr>";   
                            			SendMail($Str->eml,$subject,$message,$template_type,$attachment);   
                                        
                                        }
                                        else
										{ 	
										    
										    if($dmt->ManualAmt!=0)
										    {   
										            if($ManualSet->ManualSet>0)
													    $amount = $dmt->ManualAmt;
										    }else
										    {
                                                $MPset = $ManualSet->ManualSet -1;  
                                                $stmt=$conn->prepare("update   UI__DChstr set  ManualSet=:ManualSet where  id=:id   ");
                                                $stmt->bindValue('ManualSet', $MPset , PDO::PARAM_STR);  
                                                $stmt->bindValue('id', $dmt->id , PDO::PARAM_STR);  
                                                $stmt->execute();  
										    }
													
											if( (date("D")!="Sat") && (date("D")!="Sun"))
											{  			
													
															
													if($is_active->DPthough==0)
													{
														
														$stmt=$conn->prepare("insert into UI__DailyROIGeneClone(custId,amount,Tdate,TopUpdate,UI__DChstrId) values(:custId,:amount,:Tdate,:TopUpdate,:UI__DChstrId)"); 
														$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->bindValue(':UI__DChstrId',  $dmt->id , PDO::PARAM_STR);      
														$stmt->execute(); 
													}else {
													$stmt=$conn->prepare("insert into UI__DailyROIGene(custId,amount,Tdate,TopUpdate,UI__DChstrId) values(:custId,:amount,:Tdate,:TopUpdate,:UI__DChstrId)"); 
													$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->bindValue(':UI__DChstrId', $dmt->id , PDO::PARAM_STR);      
													$stmt->execute();  
													
													$stmt=$conn->prepare("select eml from UI__Rgst where cuurentId =:cuurentId ");   
													$stmt->bindValue(':cuurentId', $dmt->Rid, PDO::PARAM_STR);  
													$stmt->execute();  
													$Str = $stmt->fetch(PDO::FETCH_OBJ); 
													
													/// 
																						
													$stmt=$conn->prepare("select amount  from UI__DailyROIGene    where custId=:sId     ");   
													$stmt->bindValue(':sId', $dmt->Rid , 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 Tamt  from UI__Bns    where Rid =:sId   ");   
														$stmt->bindValue(':sId',  $dmt->Rid , 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',  $dmt->Rid , PDO::PARAM_INT);  
															$stmt->execute(); 
															$MdirectB = $stmt->fetchAll(PDO::FETCH_OBJ);  
															
															$directIncome = 0;
															foreach($MdirectB as $dmm)
																$directIncome += $dmm->Amt;                
														
														
													
													
													$stmt=$conn->prepare("select  amt from UI__WithDraw    where userid=:sId and (accept=1 ||accept=2)  ");   
													$stmt->bindValue(':sId',  $dmt->Rid, 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',  $dmt->Rid , PDO::PARAM_INT);  
													$stmt->execute(); 
													$UI__Fundtransfer = $stmt->fetch(PDO::FETCH_OBJ); 
													
													 
															
													$stmt=$conn->prepare("select nm  from UI__Rgst    where cuurentId=:cuurentId     ");   
													$stmt->bindValue(':cuurentId',  $dmt->Rid , PDO::PARAM_INT);  
													$stmt->execute(); 
													$UI__nm = $stmt->fetch(PDO::FETCH_OBJ);     
													$BY = $UI__nm->nm;
													
													$PAYWAllet =  ($Tamnt+$LevelI+$directIncome+$UI__Fundtransfer->availableFund)-($totalWithdrwa);        
													 
												
													$stmt=$conn->prepare("insert into  UI__DebitCredit (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',($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();
													$_SESSION['LastIntId'] = $conn->lastInsertId();;
													
													
													$stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
													$stmt->bindValue(':cuurentId',  $dmt->Rid , PDO::PARAM_STR);  
													$stmt->execute();
													$UI__Rgst = $stmt->fetch(PDO::FETCH_OBJ);   
													unset($_SESSION['LastIntId']);	
													}
															
													$subject = "Daily income generated on ".$SITE_NAME;  
													$template_type = 1;
													$attachment = '';  
													$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;'>Your daily income generated. Details are as follows </h5> 
													<h5 style='font-weight:bold; padding:2px 2px; margin:0px; text-align:center; color:#002368;'>Amount: $amount   </h5>
										
													</td>
													</tr>";   
													SendMail($Str->eml,$subject,$message,$template_type,$attachment);     
													
													
												
											}
										}     
                                }
                                else
                                {     
                                    $stmt=$conn->prepare("update UI__DChstr set status=1 where id=:id"); 
                                    $stmt->bindValue(':id', $dmt->id , PDO::PARAM_STR);    
                                    $stmt->execute();   
                                }  
                        
                    }// if end
                       
					}// for end     
					   
                                $stmt=$conn->prepare("insert into UI__GrabPayment(custId,amount,Tdate) values(:custId,:amount,:Tdate)"); 
                                $stmt->bindValue(':custId', 'DP385611' , PDO::PARAM_INT);   
                                $stmt->bindValue(':amount', 1000 , PDO::PARAM_INT);    
                                $stmt->bindValue(':Tdate',  date("d-M-Y") , PDO::PARAM_STR); 
                                $stmt->execute();  
                                AddFundNew('DP385611',1000,'Grab Payment'); 
        		 
	               }
	               
	                echo "COMPLETED";
	            
	           
	      
