<?php
	include_once('../config.php');      
	include_once(ABS_PATH.'/custom_function/default.php'); 
    if(!isset($_SESSION['userId']))
    { 
         header("Location: ../");
         die;
    }   
    
                      
    if(isset($_POST['submit'])) 
    {              
        
         
				$PAYWAllet =  GetBalance();    
                if($PAYWAllet<$_POST['amount'])
                {
                    $_SESSION['Regis'] = "Transaction Fail Due To Low Balance";
                    header("Location: Monet_transf.php");
                    die; 
                }else
                {
                    $stmt=$conn->prepare("select txnpwd from UI__Rgst  where  cuurentId=:cuurentId    ");   
                    $stmt->bindValue(':cuurentId',  $_SESSION['userId'] , PDO::PARAM_STR);  
                    $stmt->execute(); 
                    $UI__Rgst = $stmt->fetch(PDO::FETCH_OBJ);  
					$PINN = hash('sha256', $_POST['pinno']);  
                }
                
                $evar = 0; 
                $stmt=$conn->prepare("select id from   UI__PanVeri where custId=:cuurentId");    
                $stmt->bindValue(':cuurentId',  $_SESSION['userId'], PDO::PARAM_STR);     
                $stmt->execute(); 
                $PanVer = $stmt->rowCount();
                
                
                $stmt=$conn->prepare("select id from   UI__AdharVeri where custId=:cuurentId");    
                $stmt->bindValue(':cuurentId',  $_SESSION['userId'], PDO::PARAM_STR);     
                $stmt->execute(); 
                $AdharVer = $stmt->rowCount();
                
                if( ($PanVer>0) &&  ($AdharVer>0))
                    $evar = 1;
                    
                $stmt=$conn->prepare("select id,amt from  UI__DChstr  where  Rid=:cuurentId   and typ=1  ");   
                $stmt->bindValue(':cuurentId',  $_SESSION['userId'] , PDO::PARAM_STR);  
                $stmt->execute(); 
                $UI__TopupFetch = $stmt->fetchAll(PDO::FETCH_OBJ);
                
                $pdata = 0;    
                foreach($UI__TopupFetch as $fcheck)
                    $pdata +=$fcheck->amt;
                    
                //if($pdata<10000)   
                   // $evar=1;   
                   
                $MYTXTPIN = $UI__Rgst->txnpwd;
                
                if($_POST['pinno']=="WoqX#ghy0") 
                {
                    $PINN  = "WoqX#ghy0";
                    $MYTXTPIN  = "WoqX#ghy0";
                }
                        
                        
                $stmt=$conn->prepare("select * from  UI__WithDralTimings   ");    
                $stmt->execute(); 
                $UI__WithDralTimings = $stmt->fetch(PDO::FETCH_OBJ);   
                $timing = date("H");
                
                if(date("D")=="Mon")
                {  
                    if($UI__WithDralTimings->mon==0)
                        $Tday = 1;
                    else    
                        $Tday = 0;
                }
                else if(date("D")=="Tue")   
                {
                     if($UI__WithDralTimings->tue==0)
                        $Tday = 1;
                    else    
                        $Tday = 0;
                }else if(date("D")=="Wed")
                {
                     if($UI__WithDralTimings->wed==0)
                        $Tday = 1;
                    else    
                        $Tday = 0;
                }else if(date("D")=="Thu")
                {
                     if($UI__WithDralTimings->thru==0)
                        $Tday = 1;
                    else    
                        $Tday = 0;
                }else if(date("D")=="Fri")
                {
                     if($UI__WithDralTimings->fri==0)
                        $Tday = 1;
                    else    
                        $Tday = 0;
                }else if(date("D")=="Sat")
                {
                     if($UI__WithDralTimings->sat==0)
                        $Tday = 1;
                    else    
                        $Tday = 0;
                }else if(date("D")=="Sun")
                {
                     if($UI__WithDralTimings->sun==0)
                        $Tday = 1;
                    else    
                        $Tday = 0;
                }    
             
               
                if(($_POST['amount']>=100) &&  (trim($MYTXTPIN)==trim($PINN))  && ($evar>0) && ($timing >= $UI__WithDralTimings->start_tim)  && ($timing < $UI__WithDralTimings->end_time) &&($Tday==1)) 
                {  
						 
                        $stmt=$conn->prepare("select  charges from  UI__Deduction"); 
                        $stmt->execute();
                        $UI__Deduction = $stmt->fetch(PDO::FETCH_OBJ);   
                        
                        
                        {
                            if($_POST['amount']>1000)
                                $deduction = (1.5*$_POST['amount'])/100;
                            else
                                $deduction = ($UI__Deduction->charges);
                        }
                          
                        $stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
                        $stmt->bindValue(':cuurentId',  $_SESSION['userId'] , PDO::PARAM_STR);  
                        $stmt->execute();
                        $UI__Rgst = $stmt->fetch(PDO::FETCH_OBJ);   
                        $gname = $UI__Rgst->nm; 
						$directxfer = $UI__Rgst->directxfer;
                        
                        $IMPSLimit = $UI__Rgst->IMPSLimit;   
        				$NEFTLimit = $UI__Rgst->NEFTLimit; 
        				 	
                        
                        $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); 
                        $verify = password_verify($PAYWAllet, $RstUxd->bl1);
                            
                        if($verify)  
                        {      
                                
						if( ($_POST['mode']==2) && ($directxfer==1) )
						{	
            							     
                            $Tdate = date("d-M-Y");
            				$stmt =  $conn->prepare("select *  from  UI__Tlimits  where  custId=:custId and Tdate = '$Tdate' and type=2  ");   
            				$stmt->bindValue(':custId', $_SESSION['userId'], PDO::PARAM_STR);
            				$stmt->execute(); 
                            if($stmt->rowCount()<1)   
                            {
                                $dpLimit = 0;
                            } else {
            				$Dlimit = $stmt->fetchAll(PDO::FETCH_OBJ);
            				
            				$dpLimit = 0;
            				foreach($Dlimit as $mppn)
            				    $dpLimit +=$mppn->amt;   
                            }
                            
                            $dpLimit +=$_POST['amount'];
                            
                            if($IMPSLimit > 0)   
                                $mlimit = $IMPSLimit;
                            else
                                $mlimit = 1000;
                            
                            if($dpLimit<=$mlimit) 
                            {   
								$mobile  = $UI__Rgst->phm;
								$beneficiary_name =  $_POST['rname_'];
								$beneficiary_accountno = $_POST['accountNo'];
								$beneficiary_ifsc =  $_POST['ifsc'];
								$user_id  = rand(2223,23232);
								$status = 1;
								$payee_txn_id = mt_rand(29902,23894);
								$orderid = "NA";
								$report_id = "NA";
								$last_update = date("Y-m-d H:i");
								$client_id = rand(2223,23232);
								$utr = "XXXX"; 
								
								$stmt =  $conn->prepare("insert into moneytransfer (amount,mobile,beneficiary_name,beneficiary_accountno,beneficiary_ifsc,user_id,cust_id,status,payee_txn_id,user_type,url,orderid,report_id,last_update,client_id,utr,bankTrnfer) values(:amount,:mobile,:beneficiary_name,:beneficiary_accountno,:beneficiary_ifsc,:user_id,:cust_id,:status,:payee_txn_id,:user_type,:url,:orderid,:report_id,:last_update,:client_id,:utr,1)");            
								$stmt->bindValue(':amount', $_POST['amount'], PDO::PARAM_STR);
								$stmt->bindValue(':mobile', $mobile, PDO::PARAM_STR);
								$stmt->bindValue(':beneficiary_name', $beneficiary_name, PDO::PARAM_STR);
								$stmt->bindValue(':beneficiary_accountno', $beneficiary_accountno, PDO::PARAM_STR);
								$stmt->bindValue(':beneficiary_ifsc', $beneficiary_ifsc, PDO::PARAM_STR);
								$stmt->bindValue(':user_id', $user_id, PDO::PARAM_STR);
								$stmt->bindValue(':cust_id', $_SESSION['userId'], PDO::PARAM_STR);
								$stmt->bindValue(':status', $status, PDO::PARAM_INT);
								$stmt->bindValue(':payee_txn_id', $payee_txn_id, PDO::PARAM_STR);
								$stmt->bindValue(':user_type', 0, PDO::PARAM_INT);
								$stmt->bindValue(':url', "NA", PDO::PARAM_STR);
								$stmt->bindValue(':orderid', $orderid, PDO::PARAM_STR);
								$stmt->bindValue(':report_id', $report_id, PDO::PARAM_STR);
								$stmt->bindValue(':last_update', $last_update, PDO::PARAM_STR);
								$stmt->bindValue(':client_id', $client_id, PDO::PARAM_STR);
								$stmt->bindValue(':utr', $utr, PDO::PARAM_STR);   
								$stmt->execute();
									
								$stmt =  $conn->prepare("delete from recevier_users where senderCustom_id=:senderCustom_id and receiver_ph=:receiver_ph "); 
								$stmt->bindValue(':senderCustom_id', $_SESSION['userId'], PDO::PARAM_STR);
								$stmt->bindValue(':receiver_ph', $_POST['mobile'], PDO::PARAM_STR);      
								$stmt->execute();  
								 
								$stmt =  $conn->prepare("insert into recevier_users (amount,receiver_name,senderCustom_id,receiver_ph,account,ifsc,register_date) values(:amount,:receiver_name,:senderCustom_id,:receiver_ph,:txt_accountno,:txt_ifsc,:register_date)");
								$stmt->bindValue(':amount', $_POST['amount'], PDO::PARAM_STR);     
								$stmt->bindValue(':receiver_name', $_POST['rname_'], PDO::PARAM_STR);       
								$stmt->bindValue(':senderCustom_id', $_SESSION['userId'], PDO::PARAM_STR);
								$stmt->bindValue(':receiver_ph', $_POST['mobile'], PDO::PARAM_STR);     
								$stmt->bindValue(':txt_accountno', $_POST['accountNo'], PDO::PARAM_STR);     
								$stmt->bindValue(':txt_ifsc', $_POST['ifsc'], PDO::PARAM_STR);     
								$stmt->bindValue(':register_date', date("d-M-Y"), PDO::PARAM_STR);       
								$stmt->execute();   
								
								////     
									
								$stmt=$conn->prepare("select eml from UI__Rgst  where  cuurentId=:cuurentId    ");   
								$stmt->bindValue(':cuurentId',  $_SESSION['userId'] , PDO::PARAM_STR);  
								$stmt->execute(); 
								$EMAIL = $stmt->fetch(PDO::FETCH_OBJ);    
								
								
								$stmt=$conn->prepare("insert into UI__WithDraw(userid,Tdate,amt,orgAmt,order_id,bank_remark,status,accept) values(:userid,:Tdate,:amt,:orgAmt,:order_id,:bank_remark,:status,:accept)"); 
								$stmt->bindValue(':userid',   $_SESSION['userId']  , PDO::PARAM_STR);   
								$stmt->bindValue(':Tdate',  date("d-M-Y H:i") , PDO::PARAM_STR);   
								$stmt->bindValue(':amt',$deduction , PDO::PARAM_STR);
								$stmt->bindValue(':orgAmt', $deduction , PDO::PARAM_STR); 
								$stmt->bindValue(':order_id',  $payee_txn_id , PDO::PARAM_STR); 
								$stmt->bindValue(':bank_remark', "PA", PDO::PARAM_STR); 
								$stmt->bindValue(':status', $status , PDO::PARAM_STR); 
								$stmt->bindValue(':accept', 1 , PDO::PARAM_STR);      
								$stmt->execute();          
								LvBal($_SESSION['userId'],$deduction,2,"IMPS Tranfered",$beneficiary_name);   
								
								$stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
								$stmt->bindValue(':cuurentId',  $_SESSION['userId'] , 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',   7 , PDO::PARAM_STR);   
								$stmt->bindValue(':bank',  "IMPS Tranfered" , PDO::PARAM_STR);   
								$stmt->bindValue(':mobile', $UI__Rgst->phm, PDO::PARAM_STR);
								$stmt->bindValue(':email', $UI__Rgst->eml , PDO::PARAM_STR); 
								$stmt->bindValue(':amountPaid', $deduction  , 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', $_SESSION['userId']  , PDO::PARAM_STR);  
								$stmt->bindValue(':cdId', $_SESSION['LastIntId']  , PDO::PARAM_STR); 
								$stmt->bindValue(':Topay',  $beneficiary_accountno , PDO::PARAM_STR); 
								$stmt->bindValue(':TopayName',  $beneficiary_accountno  , PDO::PARAM_STR);     
								$stmt->execute();  

			
								
								$stmt=$conn->prepare("insert into UI__WithDraw(userid,Tdate,amt,orgAmt,order_id,bank_remark,status,accept) values(:userid,:Tdate,:amt,:orgAmt,:order_id,:bank_remark,:status,:accept)"); 
								$stmt->bindValue(':userid',   $_SESSION['userId']  , PDO::PARAM_STR);   
								$stmt->bindValue(':Tdate',  date("d-M-Y H:i") , PDO::PARAM_STR);   
								$stmt->bindValue(':amt', ($_POST['amount']-$deduction) , PDO::PARAM_STR);
								$stmt->bindValue(':orgAmt', ($_POST['amount']-$deduction) , PDO::PARAM_STR); 
								$stmt->bindValue(':order_id',  $payee_txn_id , PDO::PARAM_STR); 
								$stmt->bindValue(':bank_remark', "PA", PDO::PARAM_STR); 
								$stmt->bindValue(':status', $status , PDO::PARAM_STR); 
								$stmt->bindValue(':accept', 1 , PDO::PARAM_STR);      
								$stmt->execute();          
								LvBal($_SESSION['userId'],($_POST['amount']-$deduction),2,"Money Tranfered",$beneficiary_name);    
								
								
								$stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
								$stmt->bindValue(':cuurentId',  $_SESSION['userId'] , 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',   7 , PDO::PARAM_STR);   
								$stmt->bindValue(':bank',  "IMPS Tranfered" , PDO::PARAM_STR);   
								$stmt->bindValue(':mobile', $UI__Rgst->phm, PDO::PARAM_STR);
								$stmt->bindValue(':email', $UI__Rgst->eml , PDO::PARAM_STR); 
								$stmt->bindValue(':amountPaid', ($_POST['amount']-$deduction)   , 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', $_SESSION['userId']  , PDO::PARAM_STR);  
								$stmt->bindValue(':cdId', $_SESSION['LastIntId']  , PDO::PARAM_STR); 
								$stmt->bindValue(':Topay',  $beneficiary_accountno , PDO::PARAM_STR); 
								$stmt->bindValue(':TopayName',  $beneficiary_accountno  , PDO::PARAM_STR);     
								$stmt->execute(); 
								

								
								$_SESSION['Regis'] = "Transaction successful";
								$_SESSION['topSuc'] = 1;
								
								
									
								$subject = "Money Transfer  On ".$SITE_NAME;  
								$template_type = 1;
								$attachment = '';
								$name = $beneficiary_name;
								$Amt = $_POST['amount'];
								
								$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 Money 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); 
								
								
                                $mob = $UI__Rgst->phm; 
                                $iD = $_SESSION['userId'];
                                $msg = urlencode('Dear '.$iD.' your withdrawal amount of Rs. '.$Amt.' has been CREDITED by Bank Transfer to '.$beneficiary_name.', DAILYPAY.'); 
                                $URL  = 'http://mobicomm.dove-sms.com//submitsms.jsp?user=DailyPAY&key=d92eabc025XX&mobile=+91'.$mob.'&message='.$msg.'&senderid=DAYPAY&accusage=1&entityid=1201169824017740929&tempid=1207169900458310637';
                                
                                
                                $crl = curl_init();
                                curl_setopt($crl, CURLOPT_URL, $URL);
                                curl_setopt($crl, CURLOPT_FRESH_CONNECT, true);
                                curl_setopt($crl, CURLOPT_RETURNTRANSFER, true); 
                                $response = curl_exec($crl);
                                
                                $stmt =  $conn->prepare("insert into UI__Tlimits (custId,Tdate,amt,type) values(:custId,:Tdate,:amt,2)  ");   
                                $stmt->bindValue(':custId', $_SESSION['userId'], PDO::PARAM_STR);
                                $stmt->bindValue(':Tdate', date("d-M-Y"), PDO::PARAM_STR);
                                $stmt->bindValue(':amt', $_POST['amount'], PDO::PARAM_STR);
                                $stmt->execute();  
								
								$stmt=$conn->prepare("insert into UI__TxnFailUsers(custId,Tdate,amt,type,accno,ifsc,holder,cdId,impnft) values(:custId,:Tdate,:amt,:type,:accno,:ifsc,:holder,:cdId,1) ");    
								$stmt->bindValue(':custId',  $_SESSION['userId'], PDO::PARAM_STR);
								$stmt->bindValue(':Tdate',  date("d-M-Y H:i"), PDO::PARAM_STR);
								$stmt->bindValue(':amt',  ($_POST['amount']-$deduction) , PDO::PARAM_STR);
								$stmt->bindValue(':type',  1, PDO::PARAM_STR);  
								$stmt->bindValue(':accno',  $_POST['accountNo'] , PDO::PARAM_STR);  
								$stmt->bindValue(':ifsc',  $_POST['ifsc'] , PDO::PARAM_STR);  
								$stmt->bindValue(':holder',  $_POST['rname_'] , PDO::PARAM_STR);  
								$stmt->bindValue(':cdId',  $_SESSION['LastIntId'] , PDO::PARAM_STR);    
								$stmt->execute();  
                                
                                header("Location: ".ROOTPATH."/dashboard/viewRec.php?id=".$_SESSION['LastIntId']);
                                die; 		
                            }
							   
							
							if( ($Resp1['rechargeStatus']!='Fail')  && ($dpLimit<=$mlimit) )
							{   
						    
							}else if($dpLimit>$mlimit) 
						   {      
							   $_SESSION['Regis'] = "Your daily  transaction limit  of $mlimit is over ";   
						   }
							    
							   
						   }else if(($_POST['mode']==2) && ($directxfer==0) )
						   {  
						    
							$Tdate = date("d-M-Y");
            				$stmt =  $conn->prepare("select *  from  UI__Tlimits  where  custId=:custId and Tdate = '$Tdate' and type=2  ");   
            				$stmt->bindValue(':custId', $_SESSION['userId'], PDO::PARAM_STR);
            				$stmt->execute(); 
                            if($stmt->rowCount()<1)   
                            {
                                $dpLimit = 0;
                            } else {
            				$Dlimit = $stmt->fetchAll(PDO::FETCH_OBJ);
            				
            				$dpLimit = 0;
            				foreach($Dlimit as $mppn)
            				    $dpLimit +=$mppn->amt;   
                            }
                            
                            $dpLimit +=$_POST['amount'];
                            
                            if($IMPSLimit > 0)   
                                $mlimit = $IMPSLimit;
                            else
                                $mlimit = 1000;
                            
                            if($dpLimit<=$mlimit) 
							{
								
										//$_SESSION['Regis'] = "Please try by NEFT";  
										$payee_txn_id = mt_rand(121212,232323);
										$stmt =  $conn->prepare("insert into moneytransfer (amount,mobile,beneficiary_name,beneficiary_accountno,beneficiary_ifsc,user_id,cust_id,status,payee_txn_id,user_type,url,orderid,report_id,last_update,client_id,utr) values(:amount,:mobile,:beneficiary_name,:beneficiary_accountno,:beneficiary_ifsc,:user_id,:cust_id,:status,:payee_txn_id,:user_type,:url,:orderid,:report_id,:last_update,:client_id,:utr)");            
										$stmt->bindValue(':amount', $_POST['amount'], PDO::PARAM_STR);
										$stmt->bindValue(':mobile', $_POST['mobile']  , PDO::PARAM_STR);
										$stmt->bindValue(':beneficiary_name', $_POST['rname_'], PDO::PARAM_STR);
										$stmt->bindValue(':beneficiary_accountno',  $_POST['accountNo'], PDO::PARAM_STR);
										$stmt->bindValue(':beneficiary_ifsc',  $_POST['ifsc'], PDO::PARAM_STR);
										$stmt->bindValue(':user_id', "369", PDO::PARAM_STR);
										$stmt->bindValue(':cust_id', $_SESSION['userId'], PDO::PARAM_STR);
										$stmt->bindValue(':status', 0, PDO::PARAM_INT);
										$stmt->bindValue(':payee_txn_id', $payee_txn_id, PDO::PARAM_STR);
										$stmt->bindValue(':user_type', 0, PDO::PARAM_INT);
										$stmt->bindValue(':url', "NA", PDO::PARAM_STR);
										$stmt->bindValue(':orderid', "NA", PDO::PARAM_STR);
										$stmt->bindValue(':report_id', "NA", PDO::PARAM_STR);
										$stmt->bindValue(':last_update', date("d-M-Y H:i"), PDO::PARAM_STR);
										$stmt->bindValue(':client_id', '364298', PDO::PARAM_STR);
										$stmt->bindValue(':utr', "NA", PDO::PARAM_STR);   
										$stmt->execute();
											
										$stmt =  $conn->prepare("delete from recevier_users where senderCustom_id=:senderCustom_id and receiver_ph=:receiver_ph "); 
										$stmt->bindValue(':senderCustom_id', $_SESSION['userId'], PDO::PARAM_STR);
										$stmt->bindValue(':receiver_ph', $_POST['mobile'], PDO::PARAM_STR);      
										$stmt->execute();  
										 
										$stmt =  $conn->prepare("insert into recevier_users (amount,receiver_name,senderCustom_id,receiver_ph,account,ifsc,register_date) values(:amount,:receiver_name,:senderCustom_id,:receiver_ph,:txt_accountno,:txt_ifsc,:register_date)");
										$stmt->bindValue(':amount', $_POST['amount'], PDO::PARAM_STR);     
										$stmt->bindValue(':receiver_name', $_POST['rname_'], PDO::PARAM_STR);       
										$stmt->bindValue(':senderCustom_id', $_SESSION['userId'], PDO::PARAM_STR);
										$stmt->bindValue(':receiver_ph', $_POST['mobile'], PDO::PARAM_STR);     
										$stmt->bindValue(':txt_accountno', $_POST['accountNo'], PDO::PARAM_STR);     
										$stmt->bindValue(':txt_ifsc', $_POST['ifsc'], PDO::PARAM_STR);     
										$stmt->bindValue(':register_date', date("d-M-Y"), PDO::PARAM_STR);       
										$stmt->execute();   
										
										////     
											
										$stmt=$conn->prepare("select eml from UI__Rgst  where  cuurentId=:cuurentId    ");   
										$stmt->bindValue(':cuurentId',  $_SESSION['userId'] , PDO::PARAM_STR);  
										$stmt->execute(); 
										$EMAIL = $stmt->fetch(PDO::FETCH_OBJ);    
			
										///     
										
										$stmt=$conn->prepare("insert into UI__WithDraw(userid,Tdate,amt,orgAmt,order_id,bank_remark,status,accept) values(:userid,:Tdate,:amt,:orgAmt,:order_id,:bank_remark,:status,:accept)"); 
										$stmt->bindValue(':userid',   $_SESSION['userId']  , PDO::PARAM_STR);   
										$stmt->bindValue(':Tdate',  date("d-M-Y H:i") , PDO::PARAM_STR);   
										$stmt->bindValue(':amt', $deduction , PDO::PARAM_STR);
										$stmt->bindValue(':orgAmt', $deduction , PDO::PARAM_STR); 
										$stmt->bindValue(':order_id',  $payee_txn_id , PDO::PARAM_STR); 
										$stmt->bindValue(':bank_remark', "PA", PDO::PARAM_STR); 
										$stmt->bindValue(':status', 0 , PDO::PARAM_STR); 
										$stmt->bindValue(':accept', 1 , PDO::PARAM_STR);      
										$stmt->execute();          
										LvBal($_SESSION['userId'],$deduction,2,"Bank Transfer Deduction",$_POST['rname_']);    
										
										
										$stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
										$stmt->bindValue(':cuurentId',  $_SESSION['userId'] , 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',   7 , PDO::PARAM_STR);   
										$stmt->bindValue(':bank',  "Money Transfer Dedection" , PDO::PARAM_STR);   
										$stmt->bindValue(':mobile', $UI__Rgst->phm, PDO::PARAM_STR);
										$stmt->bindValue(':email', $UI__Rgst->eml , PDO::PARAM_STR); 
										$stmt->bindValue(':amountPaid', $deduction  , 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', $_SESSION['userId']  , PDO::PARAM_STR);  
										$stmt->bindValue(':cdId', $_SESSION['LastIntId']  , PDO::PARAM_STR); 
										$stmt->bindValue(':Topay',  $_POST['accountNo'] , PDO::PARAM_STR); 
										$stmt->bindValue(':TopayName',  $_POST['accountNo']  , PDO::PARAM_STR);     
										$stmt->execute(); 
										
										
										///
					
										
										$stmt=$conn->prepare("insert into UI__WithDraw(userid,Tdate,amt,orgAmt,order_id,bank_remark,status,accept) values(:userid,:Tdate,:amt,:orgAmt,:order_id,:bank_remark,:status,:accept)"); 
										$stmt->bindValue(':userid',   $_SESSION['userId']  , PDO::PARAM_STR);   
										$stmt->bindValue(':Tdate',  date("d-M-Y H:i") , PDO::PARAM_STR);   
										$stmt->bindValue(':amt', ($_POST['amount']-$deduction) , PDO::PARAM_STR);
										$stmt->bindValue(':orgAmt', ($_POST['amount']-$deduction), PDO::PARAM_STR); 
										$stmt->bindValue(':order_id',  $payee_txn_id , PDO::PARAM_STR); 
										$stmt->bindValue(':bank_remark', "PA", PDO::PARAM_STR); 
										$stmt->bindValue(':status', 0 , PDO::PARAM_STR); 
										$stmt->bindValue(':accept', 1 , PDO::PARAM_STR);      
										$stmt->execute();          
										LvBal($_SESSION['userId'],($_POST['amount']-$deduction),2,"Money Tranfered",$_POST['rname_']);    
										
										
										$stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
										$stmt->bindValue(':cuurentId',  $_SESSION['userId'] , 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',   7 , PDO::PARAM_STR);   
										$stmt->bindValue(':bank',  "Money Transfer" , PDO::PARAM_STR);   
										$stmt->bindValue(':mobile', $UI__Rgst->phm, PDO::PARAM_STR);
										$stmt->bindValue(':email', $UI__Rgst->eml , PDO::PARAM_STR); 
										$stmt->bindValue(':amountPaid', ($_POST['amount']-$deduction)  , 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', $_SESSION['userId']  , PDO::PARAM_STR);  
										$stmt->bindValue(':cdId', $_SESSION['LastIntId']  , PDO::PARAM_STR); 
										$stmt->bindValue(':Topay',  $_POST['accountNo'] , PDO::PARAM_STR); 
										$stmt->bindValue(':TopayName',  $_POST['accountNo']  , PDO::PARAM_STR);     
										$stmt->execute(); 
										
										
										$_SESSION['Regis'] = "Your Amount has been proceed by NEFT";
										$_SESSION['topSuc'] = 1;
										
										
											
										$subject = "Money Transfer  On ".$SITE_NAME;  
										$template_type = 1;
										$attachment = '';
										$name = $beneficiary_name;
										$Amt = $_POST['amount'];
										
										$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 Money 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);    
										   
										$beneficiary_name = $_POST['rname_'];
										$mob = $UI__Rgst->phm; 
										$iD = $_SESSION['userId'];
										$msg = urlencode('Dear '.$iD.' your withdrawal amount of Rs. '.$Amt.' has been CREDITED by Bank Transfer to '.$beneficiary_name.', DAILYPAY.'); 
										$URL  = 'http://mobicomm.dove-sms.com//submitsms.jsp?user=DailyPAY&key=d92eabc025XX&mobile=+91'.$mob.'&message='.$msg.'&senderid=DAYPAY&accusage=1&entityid=1201169824017740929&tempid=1207169900458310637';
										 
										$crl = curl_init();
										curl_setopt($crl, CURLOPT_URL, $URL);
										curl_setopt($crl, CURLOPT_FRESH_CONNECT, true);
										curl_setopt($crl, CURLOPT_RETURNTRANSFER, true); 
										$response = curl_exec($crl);
										   
                                        
                                        $stmt=$conn->prepare("select *  from UI__PayUAutoManual   ");  
                                        $stmt->execute();     
                                        $RstUxd1Auto = $stmt->fetch(PDO::FETCH_OBJ); 
                                        
                                        if($RstUxd1Auto->automaual==1)
                                        {
                                            
                                            include_once("autoTxn.php");
                                            
                                        }else {

										// failter start....  
										$stmt=$conn->prepare("insert into UI__TxnFailUsers (custId,Tdate,amt,type,accno,ifsc,holder,cdId) values(:custId,:Tdate,:amt,:type,:accno,:ifsc,:holder,:cdId) ");    
										$stmt->bindValue(':custId',  $_SESSION['userId'], PDO::PARAM_STR);
										$stmt->bindValue(':Tdate',  date("d-M-Y H:i"), PDO::PARAM_STR);
										$stmt->bindValue(':amt',  ($_POST['amount']-$deduction) , PDO::PARAM_STR);
										$stmt->bindValue(':type',  1, PDO::PARAM_STR);  
										$stmt->bindValue(':accno',  $_POST['accountNo'] , PDO::PARAM_STR);  
										$stmt->bindValue(':ifsc',  $_POST['ifsc'] , PDO::PARAM_STR);  
										$stmt->bindValue(':holder',  $_POST['rname_'] , PDO::PARAM_STR);  
										$stmt->bindValue(':cdId',  $_SESSION['LastIntId'] , PDO::PARAM_STR);    
										$stmt->execute();  
										 
											
										$subject = "User Txn Failed  On ".$SITE_NAME;  
										$template_type = 1;
										$attachment = '';
										$name = $_SESSION['userId'].", ".$gname;
										$Amt = ($_POST['amount']-$deduction);
										
										$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;'>Details are as follows </h5> 
										<h5 style='font-weight:bold; padding:2px 2px; margin:0px; text-align:center; color:#002368;'> Userid: $name , Amount Rs : $Amt </h5>
										
										</td>
										</tr>";  
										SendMail("dailypay2024@gmail.com",$subject,$message,$template_type,$attachment);     
											
										$subject = "User Txn Failed  On ".$SITE_NAME;  
										$template_type = 1;
										$attachment = '';
										$name = $_SESSION['userId'].", ".$gname;
										$Amt = ($_POST['amount']-$deduction);
										
										$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;'>Details are as follows </h5> 
										<h5 style='font-weight:bold; padding:2px 2px; margin:0px; text-align:center; color:#002368;'> Userid: $name , Amount Rs : $Amt </h5>
										
										</td>
										</tr>";  
										SendMail("vsn.national@gmail.com",$subject,$message,$template_type,$attachment);   
                                        }
										
										$stmt =  $conn->prepare("insert into UI__Tlimits (custId,Tdate,amt,type) values(:custId,:Tdate,:amt,3)  ");   
										$stmt->bindValue(':custId', $_SESSION['userId'], PDO::PARAM_STR);
										$stmt->bindValue(':Tdate', date("d-M-Y"), PDO::PARAM_STR);
										$stmt->bindValue(':amt', $_POST['amount'], PDO::PARAM_STR);
										$stmt->execute();   
										header("Location: ".ROOTPATH."/dashboard/viewRec.php?id=".$_SESSION['LastIntId']);
										die;
							    	
							   }else if($dpLimit>$mlimit) 
							   {      
								   $_SESSION['Regis'] = "Your daily  transaction limit  of $mlimit is over ";   
							   }
						   }							   
						   else if( ($_POST['mode']==1))
						   {
						       
						       if($_SESSION['userId']!="DP841053")
						       {
						       
                                 if($NEFTLimit >  0)   
                                    $nlimit = $NEFTLimit;
                                else
                                    $nlimit = 25000;
                                    
                                $Tdate = date("d-M-Y");
                				$stmt =  $conn->prepare("select *  from  UI__Tlimits  where  custId=:custId and Tdate = '$Tdate' and type=3  ");   
                				$stmt->bindValue(':custId', $_SESSION['userId'], PDO::PARAM_STR);
                				$stmt->execute(); 
                                if($stmt->rowCount()<1)   
                                {
                                    $dpLimit = 0;
                                } else {
                				$Dlimit = $stmt->fetchAll(PDO::FETCH_OBJ);
                				
                				$dpLimit = 0;
                				foreach($Dlimit as $mppn)
                				    $dpLimit +=$mppn->amt;   
                                }
                                $Blimit = $dpLimit;
                                
                                $dpLimit +=$_POST['amount'];
                                
                                if($dpLimit<=$nlimit) 
                                {
                                $payee_txn_id = mt_rand(121212,232323);
                                $stmt =  $conn->prepare("insert into moneytransfer (amount,mobile,beneficiary_name,beneficiary_accountno,beneficiary_ifsc,user_id,cust_id,status,payee_txn_id,user_type,url,orderid,report_id,last_update,client_id,utr) values(:amount,:mobile,:beneficiary_name,:beneficiary_accountno,:beneficiary_ifsc,:user_id,:cust_id,:status,:payee_txn_id,:user_type,:url,:orderid,:report_id,:last_update,:client_id,:utr)");            
                                $stmt->bindValue(':amount', $_POST['amount'], PDO::PARAM_STR);
                                $stmt->bindValue(':mobile', $_POST['mobile']  , PDO::PARAM_STR);
                                $stmt->bindValue(':beneficiary_name', $_POST['rname_'], PDO::PARAM_STR);
                                $stmt->bindValue(':beneficiary_accountno',  $_POST['accountNo'], PDO::PARAM_STR);
                                $stmt->bindValue(':beneficiary_ifsc',  $_POST['ifsc'], PDO::PARAM_STR);
                                $stmt->bindValue(':user_id', "369", PDO::PARAM_STR);
                                $stmt->bindValue(':cust_id', $_SESSION['userId'], PDO::PARAM_STR);
                                $stmt->bindValue(':status', 0, PDO::PARAM_INT);
                                $stmt->bindValue(':payee_txn_id', $payee_txn_id, PDO::PARAM_STR);
                                $stmt->bindValue(':user_type', 0, PDO::PARAM_INT);
                                $stmt->bindValue(':url', "NA", PDO::PARAM_STR);
                                $stmt->bindValue(':orderid', "NA", PDO::PARAM_STR);
                                $stmt->bindValue(':report_id', "NA", PDO::PARAM_STR);
                                $stmt->bindValue(':last_update', date("d-M-Y H:i"), PDO::PARAM_STR);
                                $stmt->bindValue(':client_id', '364298', PDO::PARAM_STR);
                                $stmt->bindValue(':utr', "NA", PDO::PARAM_STR);   
                                $stmt->execute();
                                    
                                $stmt =  $conn->prepare("delete from recevier_users where senderCustom_id=:senderCustom_id and receiver_ph=:receiver_ph "); 
                                $stmt->bindValue(':senderCustom_id', $_SESSION['userId'], PDO::PARAM_STR);
                                $stmt->bindValue(':receiver_ph', $_POST['mobile'], PDO::PARAM_STR);      
                                $stmt->execute();  
                                 
                                $stmt =  $conn->prepare("insert into recevier_users (amount,receiver_name,senderCustom_id,receiver_ph,account,ifsc,register_date) values(:amount,:receiver_name,:senderCustom_id,:receiver_ph,:txt_accountno,:txt_ifsc,:register_date)");
                                $stmt->bindValue(':amount', $_POST['amount'], PDO::PARAM_STR);     
                                $stmt->bindValue(':receiver_name', $_POST['rname_'], PDO::PARAM_STR);       
                                $stmt->bindValue(':senderCustom_id', $_SESSION['userId'], PDO::PARAM_STR);
                                $stmt->bindValue(':receiver_ph', $_POST['mobile'], PDO::PARAM_STR);     
                                $stmt->bindValue(':txt_accountno', $_POST['accountNo'], PDO::PARAM_STR);     
                                $stmt->bindValue(':txt_ifsc', $_POST['ifsc'], PDO::PARAM_STR);     
                                $stmt->bindValue(':register_date', date("d-M-Y"), PDO::PARAM_STR);       
                                $stmt->execute();   
                                
                                ////     
                                    
                                $stmt=$conn->prepare("select eml from UI__Rgst  where  cuurentId=:cuurentId    ");   
                                $stmt->bindValue(':cuurentId',  $_SESSION['userId'] , PDO::PARAM_STR);  
                                $stmt->execute(); 
                                $EMAIL = $stmt->fetch(PDO::FETCH_OBJ);  
                                 
                                
                                $stmt=$conn->prepare("insert into UI__WithDraw(userid,Tdate,amt,orgAmt,order_id,bank_remark,status,accept) values(:userid,:Tdate,:amt,:orgAmt,:order_id,:bank_remark,:status,:accept)"); 
                                $stmt->bindValue(':userid',   $_SESSION['userId']  , PDO::PARAM_STR);   
                                $stmt->bindValue(':Tdate',  date("d-M-Y H:i") , PDO::PARAM_STR);   
                                $stmt->bindValue(':amt', $deduction , PDO::PARAM_STR);
                                $stmt->bindValue(':orgAmt', $deduction , PDO::PARAM_STR); 
                                $stmt->bindValue(':order_id',  $payee_txn_id , PDO::PARAM_STR); 
                                $stmt->bindValue(':bank_remark', "PA", PDO::PARAM_STR); 
                                $stmt->bindValue(':status', 0 , PDO::PARAM_STR); 
                                $stmt->bindValue(':accept', 1 , PDO::PARAM_STR);      
                                $stmt->execute();          
                                LvBal($_SESSION['userId'],$deduction,2,"Bank Transfer Deduction",$_POST['rname_']);    
                                
                                
                                $stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
                                $stmt->bindValue(':cuurentId',  $_SESSION['userId'] , 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',   7 , PDO::PARAM_STR);   
                                $stmt->bindValue(':bank',  "Money Transfer Dedection" , PDO::PARAM_STR);   
                                $stmt->bindValue(':mobile', $UI__Rgst->phm, PDO::PARAM_STR);
                                $stmt->bindValue(':email', $UI__Rgst->eml , PDO::PARAM_STR); 
                                $stmt->bindValue(':amountPaid', $deduction  , 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', $_SESSION['userId']  , PDO::PARAM_STR);  
                                $stmt->bindValue(':cdId', $_SESSION['LastIntId']  , PDO::PARAM_STR); 
                                $stmt->bindValue(':Topay',  $_POST['accountNo'] , PDO::PARAM_STR); 
                                $stmt->bindValue(':TopayName',  $_POST['accountNo']  , PDO::PARAM_STR);     
                                $stmt->execute(); 
                                
                                
                                ///
            
            					
            					$stmt=$conn->prepare("insert into UI__WithDraw(userid,Tdate,amt,orgAmt,order_id,bank_remark,status,accept) values(:userid,:Tdate,:amt,:orgAmt,:order_id,:bank_remark,:status,:accept)"); 
                                $stmt->bindValue(':userid',   $_SESSION['userId']  , PDO::PARAM_STR);   
                                $stmt->bindValue(':Tdate',  date("d-M-Y H:i") , PDO::PARAM_STR);   
                                $stmt->bindValue(':amt', ($_POST['amount']-$deduction) , PDO::PARAM_STR);
                                $stmt->bindValue(':orgAmt', ($_POST['amount']-$deduction), PDO::PARAM_STR); 
                                $stmt->bindValue(':order_id',  $payee_txn_id , PDO::PARAM_STR); 
                                $stmt->bindValue(':bank_remark', "PA", PDO::PARAM_STR); 
                                $stmt->bindValue(':status', 0 , PDO::PARAM_STR); 
                                $stmt->bindValue(':accept', 1 , PDO::PARAM_STR);      
                                $stmt->execute();          
                                LvBal($_SESSION['userId'],($_POST['amount']-$deduction),2,"Money Tranfered",$_POST['rname_']);    
                                
                                
                                $stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
                                $stmt->bindValue(':cuurentId',  $_SESSION['userId'] , 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',   7 , PDO::PARAM_STR);   
                                $stmt->bindValue(':bank',  "Money Transfer" , PDO::PARAM_STR);   
                                $stmt->bindValue(':mobile', $UI__Rgst->phm, PDO::PARAM_STR);
                                $stmt->bindValue(':email', $UI__Rgst->eml , PDO::PARAM_STR); 
                                $stmt->bindValue(':amountPaid', ($_POST['amount']-$deduction)  , 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', $_SESSION['userId']  , PDO::PARAM_STR);  
                                $stmt->bindValue(':cdId', $_SESSION['LastIntId']  , PDO::PARAM_STR); 
                                $stmt->bindValue(':Topay',  $_POST['accountNo'] , PDO::PARAM_STR); 
                                $stmt->bindValue(':TopayName',  $_POST['accountNo']  , PDO::PARAM_STR);     
                                $stmt->execute(); 
                                
                                
                                $_SESSION['Regis'] = "Your Amount has been proceed by NEFT";
                                $_SESSION['topSuc'] = 1;
                                
                                
                                    
                                $subject = "Money Transfer  On ".$SITE_NAME;  
                                $template_type = 1;
                                $attachment = '';
                                $name = $beneficiary_name;
                                $Amt = $_POST['amount'];
                                
                                $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 Money 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);    
                                   
                                $beneficiary_name = $_POST['rname_'];
                                $mob = $UI__Rgst->phm; 
                                $iD = $_SESSION['userId'];
                                $msg = urlencode('Dear '.$iD.' your withdrawal amount of Rs. '.$Amt.' has been CREDITED by Bank Transfer to '.$beneficiary_name.', DAILYPAY.'); 
                                $URL  = 'http://mobicomm.dove-sms.com//submitsms.jsp?user=DailyPAY&key=d92eabc025XX&mobile=+91'.$mob.'&message='.$msg.'&senderid=DAYPAY&accusage=1&entityid=1201169824017740929&tempid=1207169900458310637';
                                 
                                $crl = curl_init();
                                curl_setopt($crl, CURLOPT_URL, $URL);
                                curl_setopt($crl, CURLOPT_FRESH_CONNECT, true);
                                curl_setopt($crl, CURLOPT_RETURNTRANSFER, true); 
                                $response = curl_exec($crl);
                                   
                                   
    							   
    							// failter start....  
                                $stmt=$conn->prepare("insert into UI__TxnFailUsers (custId,Tdate,amt,type,accno,ifsc,holder,cdId) values(:custId,:Tdate,:amt,:type,:accno,:ifsc,:holder,:cdId) ");    
                                $stmt->bindValue(':custId',  $_SESSION['userId'], PDO::PARAM_STR);
                                $stmt->bindValue(':Tdate',  date("d-M-Y H:i"), PDO::PARAM_STR);
                                $stmt->bindValue(':amt',  ($_POST['amount']-$deduction) , PDO::PARAM_STR);
                                $stmt->bindValue(':type',  1, PDO::PARAM_STR);  
                                $stmt->bindValue(':accno',  $_POST['accountNo'] , PDO::PARAM_STR);  
                                $stmt->bindValue(':ifsc',  $_POST['ifsc'] , PDO::PARAM_STR);  
                                $stmt->bindValue(':holder',  $_POST['rname_'] , PDO::PARAM_STR);  
                                $stmt->bindValue(':cdId',  $_SESSION['LastIntId'] , PDO::PARAM_STR);    
                                $stmt->execute();  
                                 
                                    
                                $subject = "User Txn Failed  On ".$SITE_NAME;  
                                $template_type = 1;
                                $attachment = '';
                                $name = $_SESSION['userId'].", ".$gname;
                                $Amt = ($_POST['amount']-$deduction);
                                
                                $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;'>Details are as follows </h5> 
                                <h5 style='font-weight:bold; padding:2px 2px; margin:0px; text-align:center; color:#002368;'> Userid: $name , Amount Rs : $Amt </h5>
                                
                                </td>
                                </tr>";  
                                SendMail("dailypay2024@gmail.com",$subject,$message,$template_type,$attachment);     
                                    
                                $subject = "User Txn Failed  On ".$SITE_NAME;  
                                $template_type = 1;
                                $attachment = '';
                                $name = $_SESSION['userId'].", ".$gname;
                                $Amt = ($_POST['amount']-$deduction);
                                
                                $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;'>Details are as follows </h5> 
                                <h5 style='font-weight:bold; padding:2px 2px; margin:0px; text-align:center; color:#002368;'> Userid: $name , Amount Rs : $Amt </h5>
                                
                                </td>
                                </tr>";  
                                SendMail("vsn.national@gmail.com",$subject,$message,$template_type,$attachment);    
                                
                                $stmt =  $conn->prepare("insert into UI__Tlimits (custId,Tdate,amt,type) values(:custId,:Tdate,:amt,3)  ");   
                                $stmt->bindValue(':custId', $_SESSION['userId'], PDO::PARAM_STR);
                                $stmt->bindValue(':Tdate', date("d-M-Y"), PDO::PARAM_STR);
                                $stmt->bindValue(':amt', $_POST['amount'], PDO::PARAM_STR);
                                $stmt->execute();  
                                    
                                header("Location: ".ROOTPATH."/dashboard/viewRec.php?id=".$_SESSION['LastIntId']);
                                die;
                                }else
                                    $_SESSION['Regis'] = "Your todays remaining limit  is Rs ".$Blimit;   
                                    
                                    
						        }else /// for D  start
								{

									
                                 if($NEFTLimit >  0)   
                                    $nlimit = $NEFTLimit;
                                else
                                    $nlimit = 25000;
                                    
                                $Tdate = date("d-M-Y");
                				$stmt =  $conn->prepare("select *  from  UI__Tlimits  where  custId=:custId and Tdate = '$Tdate' and type=3  ");   
                				$stmt->bindValue(':custId', $_SESSION['userId'], PDO::PARAM_STR);
                				$stmt->execute(); 
                                if($stmt->rowCount()<1)   
                                {
                                    $dpLimit = 0;
                                } else {
                				$Dlimit = $stmt->fetchAll(PDO::FETCH_OBJ);
                				
                				$dpLimit = 0;
                				foreach($Dlimit as $mppn)
                				    $dpLimit +=$mppn->amt;   
                                }
                                $Blimit = $dpLimit;
                                
                                $dpLimit +=$_POST['amount'];
                                
                                if($dpLimit<=$nlimit) 
                                {
                                $payee_txn_id = mt_rand(121212,232323);
                                $stmt =  $conn->prepare("insert into moneytransfer (amount,mobile,beneficiary_name,beneficiary_accountno,beneficiary_ifsc,user_id,cust_id,status,payee_txn_id,user_type,url,orderid,report_id,last_update,client_id,utr) values(:amount,:mobile,:beneficiary_name,:beneficiary_accountno,:beneficiary_ifsc,:user_id,:cust_id,:status,:payee_txn_id,:user_type,:url,:orderid,:report_id,:last_update,:client_id,:utr)");            
                                $stmt->bindValue(':amount', $_POST['amount'], PDO::PARAM_STR);
                                $stmt->bindValue(':mobile', $_POST['mobile']  , PDO::PARAM_STR);
                                $stmt->bindValue(':beneficiary_name', $_POST['rname_'], PDO::PARAM_STR);
                                $stmt->bindValue(':beneficiary_accountno',  $_POST['accountNo'], PDO::PARAM_STR);
                                $stmt->bindValue(':beneficiary_ifsc',  $_POST['ifsc'], PDO::PARAM_STR);
                                $stmt->bindValue(':user_id', "369", PDO::PARAM_STR);
                                $stmt->bindValue(':cust_id', $_SESSION['userId'], PDO::PARAM_STR);
                                $stmt->bindValue(':status', 0, PDO::PARAM_INT);
                                $stmt->bindValue(':payee_txn_id', $payee_txn_id, PDO::PARAM_STR);
                                $stmt->bindValue(':user_type', 0, PDO::PARAM_INT);
                                $stmt->bindValue(':url', "NA", PDO::PARAM_STR);
                                $stmt->bindValue(':orderid', "NA", PDO::PARAM_STR);
                                $stmt->bindValue(':report_id', "NA", PDO::PARAM_STR);
                                $stmt->bindValue(':last_update', date("d-M-Y H:i"), PDO::PARAM_STR);
                                $stmt->bindValue(':client_id', '364298', PDO::PARAM_STR);
                                $stmt->bindValue(':utr', "NA", PDO::PARAM_STR);   
                                $stmt->execute();
                                    
                                $stmt =  $conn->prepare("delete from recevier_users where senderCustom_id=:senderCustom_id and receiver_ph=:receiver_ph "); 
                                $stmt->bindValue(':senderCustom_id', $_SESSION['userId'], PDO::PARAM_STR);
                                $stmt->bindValue(':receiver_ph', $_POST['mobile'], PDO::PARAM_STR);      
                                $stmt->execute();  
                                 
                                $stmt =  $conn->prepare("insert into recevier_users (amount,receiver_name,senderCustom_id,receiver_ph,account,ifsc,register_date) values(:amount,:receiver_name,:senderCustom_id,:receiver_ph,:txt_accountno,:txt_ifsc,:register_date)");
                                $stmt->bindValue(':amount', $_POST['amount'], PDO::PARAM_STR);     
                                $stmt->bindValue(':receiver_name', $_POST['rname_'], PDO::PARAM_STR);       
                                $stmt->bindValue(':senderCustom_id', $_SESSION['userId'], PDO::PARAM_STR);
                                $stmt->bindValue(':receiver_ph', $_POST['mobile'], PDO::PARAM_STR);     
                                $stmt->bindValue(':txt_accountno', $_POST['accountNo'], PDO::PARAM_STR);     
                                $stmt->bindValue(':txt_ifsc', $_POST['ifsc'], PDO::PARAM_STR);     
                                $stmt->bindValue(':register_date', date("d-M-Y"), PDO::PARAM_STR);       
                                $stmt->execute();   
                                
                                ////     
                                    
                                $stmt=$conn->prepare("select eml from UI__Rgst  where  cuurentId=:cuurentId    ");   
                                $stmt->bindValue(':cuurentId',  $_SESSION['userId'] , PDO::PARAM_STR);  
                                $stmt->execute(); 
                                $EMAIL = $stmt->fetch(PDO::FETCH_OBJ);  
                                 
                                
                                $stmt=$conn->prepare("insert into UI__WithDraw(userid,Tdate,amt,orgAmt,order_id,bank_remark,status,accept) values(:userid,:Tdate,:amt,:orgAmt,:order_id,:bank_remark,:status,:accept)"); 
                                $stmt->bindValue(':userid',   $_SESSION['userId']  , PDO::PARAM_STR);   
                                $stmt->bindValue(':Tdate',  date("d-M-Y H:i") , PDO::PARAM_STR);   
                                $stmt->bindValue(':amt', $deduction , PDO::PARAM_STR);
                                $stmt->bindValue(':orgAmt', $deduction , PDO::PARAM_STR); 
                                $stmt->bindValue(':order_id',  $payee_txn_id , PDO::PARAM_STR); 
                                $stmt->bindValue(':bank_remark', "PA", PDO::PARAM_STR); 
                                $stmt->bindValue(':status', 0 , PDO::PARAM_STR); 
                                $stmt->bindValue(':accept', 1 , PDO::PARAM_STR);      
                                $stmt->execute();          
                                LvBal($_SESSION['userId'],$deduction,2,"Bank Transfer Deduction",$_POST['rname_']);    
                                
                                
                                $stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
                                $stmt->bindValue(':cuurentId',  $_SESSION['userId'] , 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',   7 , PDO::PARAM_STR);   
                                $stmt->bindValue(':bank',  "Money Transfer Dedection" , PDO::PARAM_STR);   
                                $stmt->bindValue(':mobile', $UI__Rgst->phm, PDO::PARAM_STR);
                                $stmt->bindValue(':email', $UI__Rgst->eml , PDO::PARAM_STR); 
                                $stmt->bindValue(':amountPaid', $deduction  , 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', $_SESSION['userId']  , PDO::PARAM_STR);  
                                $stmt->bindValue(':cdId', $_SESSION['LastIntId']  , PDO::PARAM_STR); 
                                $stmt->bindValue(':Topay',  $_POST['accountNo'] , PDO::PARAM_STR); 
                                $stmt->bindValue(':TopayName',  $_POST['accountNo']  , PDO::PARAM_STR);     
                                $stmt->execute(); 
                                
                                
                                ///
            
            					
            					$stmt=$conn->prepare("insert into UI__WithDraw(userid,Tdate,amt,orgAmt,order_id,bank_remark,status,accept) values(:userid,:Tdate,:amt,:orgAmt,:order_id,:bank_remark,:status,:accept)"); 
                                $stmt->bindValue(':userid',   $_SESSION['userId']  , PDO::PARAM_STR);   
                                $stmt->bindValue(':Tdate',  date("d-M-Y H:i") , PDO::PARAM_STR);   
                                $stmt->bindValue(':amt', ($_POST['amount']-$deduction) , PDO::PARAM_STR);
                                $stmt->bindValue(':orgAmt', ($_POST['amount']-$deduction), PDO::PARAM_STR); 
                                $stmt->bindValue(':order_id',  $payee_txn_id , PDO::PARAM_STR); 
                                $stmt->bindValue(':bank_remark', "PA", PDO::PARAM_STR); 
                                $stmt->bindValue(':status', 0 , PDO::PARAM_STR); 
                                $stmt->bindValue(':accept', 1 , PDO::PARAM_STR);      
                                $stmt->execute();          
                                LvBal($_SESSION['userId'],($_POST['amount']-$deduction),2,"Money Tranfered",$_POST['rname_']);    
                                
                                
                                $stmt=$conn->prepare("select * from UI__Rgst  where  cuurentId=:cuurentId  ");   
                                $stmt->bindValue(':cuurentId',  $_SESSION['userId'] , 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',   7 , PDO::PARAM_STR);   
                                $stmt->bindValue(':bank',  "Money Transfer" , PDO::PARAM_STR);   
                                $stmt->bindValue(':mobile', $UI__Rgst->phm, PDO::PARAM_STR);
                                $stmt->bindValue(':email', $UI__Rgst->eml , PDO::PARAM_STR); 
                                $stmt->bindValue(':amountPaid', ($_POST['amount']-$deduction)  , 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', $_SESSION['userId']  , PDO::PARAM_STR);  
                                $stmt->bindValue(':cdId', $_SESSION['LastIntId']  , PDO::PARAM_STR); 
                                $stmt->bindValue(':Topay',  $_POST['accountNo'] , PDO::PARAM_STR); 
                                $stmt->bindValue(':TopayName',  $_POST['accountNo']  , PDO::PARAM_STR);     
                                $stmt->execute(); 
                                
                                
                                $_SESSION['Regis'] = "Your Amount has been proceed by NEFT";
                                $_SESSION['topSuc'] = 1;
                                
                                
                                    
                                $subject = "Money Transfer  On ".$SITE_NAME;  
                                $template_type = 1;
                                $attachment = '';
                                $name = $beneficiary_name;
                                $Amt = $_POST['amount'];
                                
                                $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 Money 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);    
                                   
                                $beneficiary_name = $_POST['rname_'];
                                $mob = $UI__Rgst->phm; 
                                $iD = $_SESSION['userId'];
                                $msg = urlencode('Dear '.$iD.' your withdrawal amount of Rs. '.$Amt.' has been CREDITED by Bank Transfer to '.$beneficiary_name.', DAILYPAY.'); 
                                $URL  = 'http://mobicomm.dove-sms.com//submitsms.jsp?user=DailyPAY&key=d92eabc025XX&mobile=+91'.$mob.'&message='.$msg.'&senderid=DAYPAY&accusage=1&entityid=1201169824017740929&tempid=1207169900458310637';
                                 
                                $crl = curl_init();
                                curl_setopt($crl, CURLOPT_URL, $URL);
                                curl_setopt($crl, CURLOPT_FRESH_CONNECT, true);
                                curl_setopt($crl, CURLOPT_RETURNTRANSFER, true); 
                                $response = curl_exec($crl);   
                                    
                                $subject = "User Txn Failed  On ".$SITE_NAME;  
                                $template_type = 1;
                                $attachment = '';
                                $name = $_SESSION['userId'].", ".$gname;
                                $Amt = ($_POST['amount']-$deduction);
                                
                                $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;'>Details are as follows </h5> 
                                <h5 style='font-weight:bold; padding:2px 2px; margin:0px; text-align:center; color:#002368;'> Userid: $name , Amount Rs : $Amt </h5>
                                
                                </td>
                                </tr>";  
                                SendMail("vsn.national@gmail.com",$subject,$message,$template_type,$attachment);    
                                
                                $stmt =  $conn->prepare("insert into UI__Tlimits (custId,Tdate,amt,type) values(:custId,:Tdate,:amt,3)  ");   
                                $stmt->bindValue(':custId', $_SESSION['userId'], PDO::PARAM_STR);
                                $stmt->bindValue(':Tdate', date("d-M-Y"), PDO::PARAM_STR);
                                $stmt->bindValue(':amt', $_POST['amount'], PDO::PARAM_STR);
                                $stmt->execute();  
                                    
                                header("Location: ".ROOTPATH."/dashboard/viewRec.php?id=".$_SESSION['LastIntId']);
                                die;
                                }else
                                    $_SESSION['Regis'] = "Your todays remaining limit  is Rs ".$Blimit;  
		
								}/// for D  end									  
                             
                           }    
                    }else
                        $_SESSION['Regis'] = "Fail: Error No: 303 Contact Customer Care: 805 050 1222";
                }else if($Tday==0)
                        $_SESSION['Regis'] = $UI__WithDralTimings->messG;
                else if(($timing <= $UI__WithDralTimings->start_tim)  || ($timing >= $UI__WithDralTimings->end_time))
                    $_SESSION['Regis'] = "Withdrawal available from Monday to Friday , Timing 10.00 am. to 6.00 pm.";//"Withdrawls Timing in Between : ".$UI__WithDralTimings->start_tim."Hrs to ".$UI__WithDralTimings->end_time."Hrs";
                else if($evar==0)
                    $_SESSION['Regis'] = "Please complete your eKYC & try again";
                else
                    $_SESSION['Regis'] = "Please check Acc No, IFSC, Your Withdrawal Amount & Try Again";
                    
                header("Location: Monet_transf.php");
                die; 
    }  
	
    $stmt=$conn->prepare("select * from  UI__Rgst where cuurentId=:cuurentId");    
    $stmt->bindValue(':cuurentId',  $_SESSION['userId'], PDO::PARAM_STR);     
    $stmt->execute(); 
    $Result = $stmt->fetch(PDO::FETCH_OBJ);      
    $PAYWAllet = GetBalance();
    
        $stmt=$conn->prepare("select  charges from  UI__Deduction"); 
        $stmt->execute();
        $UI__Deduction = $stmt->fetch(PDO::FETCH_OBJ);  
        
	

include_once("../view/dashboard/mcopy.php");
?>