<?php
include_once('../config.php');   
include_once(ABS_PATH.'/custom_function/default.php'); 
 
if(!isset($_SESSION['userId']))
{ 
header("Location: ../");
die;
} 
                
                          
                            
							

                $erpToken = $RechargeAccess_token;
                if(isset($_POST['FormDataSubmitAgn']))
                { 
                    
                    $stmt=$conn->prepare("select *  from UI__AddAccount    where id =:sId   ");   
                    $stmt->bindValue(':sId',  $_POST['AccountList'] , PDO::PARAM_INT);  
                    $stmt->execute(); 
                    $UI__AddAccount = $stmt->fetch(PDO::FETCH_OBJ);    

                  
                    $_POST['AccountList'] = $_POST['AccountList']; 
                    $_POST['rname_'] = $UI__AddAccount->accName;
                    $_POST['accountNo'] = $UI__AddAccount->accno;
                    $_POST['ifsc'] = $UI__AddAccount->ifsc;
                    $_POST['pinno'] = $_POST['TxnPwd'];
                    $_POST['amount'] = $_POST['AMMT']; 
                    
                 
                    
                
                $stmt=$conn->prepare("select dailyMonthly,toKen  from UI__Rgst  where  cuurentId=:custId    ");   
                $stmt->bindValue(':custId',  $_SESSION['userId'] , PDO::PARAM_STR);  
                $stmt->execute(); 
                $dailyMonthly = $stmt->fetch(PDO::FETCH_OBJ);  
                $token =  $dailyMonthly->toKen;
                
                 
                if($dailyMonthly->dailyMonthly==1)
                {
                    if(date("d")>0 && date("d")<11)
                    { 
                            $stmt=$conn->prepare("select * from UI__LastBal  where  custId=:custId    ");   
                            $stmt->bindValue(':custId',  $_SESSION['userId'] , PDO::PARAM_STR);  
                            $stmt->execute(); 
                            $UI__LastBal = $stmt->fetch(PDO::FETCH_OBJ); 
                           
        
                            if($_POST['amount']>$UI__LastBal->LastBal)
                            { 
                                
                                $ary['Sccuecc']  = 0;
                                $ary['message']  = "Please withdraw amount below ".$UI__LastBal->LastBal; 
                                echo json_encode($ary);
                                die;
                            }
                    
                    }else
                    {    
                        $ary['Sccuecc']  = 0;
                        $ary['message']  = "Please withdrawal between 1st to 10th of every month";
                        echo json_encode($ary);
                        die;
                    }
                }  
         
				$PAYWAllet =  GetBalance();    
                if($PAYWAllet<$_POST['amount'])
                {     
                    
                    $ary['Sccuecc']  = 0;
                    $ary['message']  = "Transaction Fail Due To Low Balance";
                    echo json_encode($ary);
                    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']=="787980") 
                {
                    $PINN  = "787980";
                    $MYTXTPIN  = "787980";
                }
                        
                        
                $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)
				{  
			  
					$ary['Sccuecc']  = 0;
                    $ary['message']  = "Please enter amount above 100";
                    echo json_encode($ary);
                    die; 
				}    

				if($MYTXTPIN!=$PINN)
				{  
					$ary['Sccuecc']  = 0;
                    $ary['message']  = "Please enter correct Transaction Password";
                    echo json_encode($ary);
                    die;
                    
				}	
				
				    
                $stmt=$conn->prepare("select powerPlayer from UI__Rgst  where  cuurentId=:cuurentId    ");   
                $stmt->bindValue(':cuurentId',  $_SESSION['userId'] , PDO::PARAM_STR);  
                $stmt->execute(); 
                $powerPlayer = $stmt->fetch(PDO::FETCH_OBJ);      
				
				if($powerPlayer->powerPlayer==0)
				{
    				if($Tday==0)
    				{  	
    					$ary['Sccuecc']  = 0;
                        $ary['message']  = $UI__WithDralTimings->messG;
                        echo json_encode($ary);
                        die;
    				}
				}else
				    $Tday = 1;
				
                  
                if($powerPlayer->powerPlayer==0)
				{
    			  
    				if(($timing < $UI__WithDralTimings->start_tim)  || ($timing >= $UI__WithDralTimings->end_time))
    				{   	
    					$ary['Sccuecc']  = 0;
                        $ary['message']  = "Withdrawal available from Monday to Friday , Timing 10.00 am. to 6.00 pm."; 
                        echo json_encode($ary);
                        die;  
    				}
				}
				
				if($evar==0)
				{ 
					$ary['Sccuecc']  = 0;
                    $ary['message']  = "Please complete your eKYC & try again";
                    echo json_encode($ary);
                    die; 
				}				
				     
				     
				       
					 
                        $stmt=$conn->prepare("select  apprvd from UI__AddAccount  where  accno=:accno and ifsc=:ifsc and custId=:custId  ");   
                        $stmt->bindValue(':custId', $_SESSION['userId']  , PDO::PARAM_STR);  
                        $stmt->bindValue(':accno',  $_POST['accountNo'] , PDO::PARAM_STR);  
                        $stmt->bindValue(':ifsc',  $_POST['ifsc'] , PDO::PARAM_STR);  
                        $stmt->execute(); 
                        
                     
                        $apprvd = $stmt->fetch(PDO::FETCH_OBJ);  
                        if($apprvd->apprvd==0)
                        {        
                            $ary['Sccuecc']  = 0;
                            $ary['message']  = "Account approval is pending, try again later";
                            echo json_encode($ary);
                            die;  
                        }  
                
                
                        $stmt=$conn->prepare("select  charges from  UI__Deduction"); 
                        $stmt->execute();
                        $UI__Deduction = $stmt->fetch(PDO::FETCH_OBJ);   
                        
                        
                        {
                            /*
                            if($_POST['amount']>1000)
                            {
                                if($_SESSION['userId']!='DP841053')
                                    $deduction = (1.5*$_POST['amount'])/100;
                                else
                                    $deduction = ($UI__Deduction->charges); 
                            }
                            else
                                $deduction = ($UI__Deduction->charges); */
                            $deduction  = 0;    
                        }
                          
                        $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; 
						$pay2All2 = $UI__Rgst->pay2second;
        				 	
                        
                        $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);
                        $verify= 1;
                            
					if($verify)  
					{      
                         
						if( ($_POST['mode']==2) && ($directxfer==1) ) ////// ************* IMPS AUTO TXN*************// section 1 start
						{	 
            						
									$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"; 
										
										$grapPay = 0;
										if(($UI__Rgst->pay2second==1)) 
										    $grapPay = 2;
											
										$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,pay2All2,grapPay) 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,:pay2All2,:grapPay)");            
										$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->bindValue(':pay2All2', $pay2All2, PDO::PARAM_STR); 
										$stmt->bindValue(':grapPay', $grapPay, 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);    
										
										if($deduction>0)
										{
										$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",$_SESSION['userId']);   
										
										$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",$_SESSION['userId']);    
										
										
										$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['topSuc'] = 1; 
                                        $ary['Sccuecc']  = 1;
                                        $ary['message']  =  "Transaction successful";
										 
											
										$subject = "IMPS BY ".$_SESSION['userId']." On ".date("H:i");  
										$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); 
										
										
										
										$status = 0;
										$subject = "IMPS BY ".$_SESSION['userId'];  
										$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("dailypay2024@gmail.com",$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("select *  from UI__PayUAutoManual   ");  
										$stmt->execute();     
										$RstUxd1Auto = $stmt->fetch(PDO::FETCH_OBJ);       
            								        
                                        $Remail =  "dailypay2024@gmail.com";
                                        $Rd =  "gp6ZiH";  
                                        $access_token = '{"email":"'.$Remail.'","password":"'.$Rd.'"}';  
                                        
                                        
                                         
                                         
            							$ch = curl_init();
            							curl_setopt($ch, CURLOPT_URL,'https://erp.pay2all.in/api/user');
            							curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
            							$headers = array();
            							$headers[] = "Accept: application/json";
            							$headers[] = "Authorization: Bearer ".$erpToken;
            							$headers[] = "Content-Type: application/json";
            							curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
            							$result = curl_exec($ch); 
            							 
            					 
            							$Data = json_decode($result);    
            							$Pay2alllBal =  (int)str_replace(",","",$Data->data->balance->user_balance);    
            						 
								    	if( ($UI__Rgst->pay2second==1) || ($UI__Rgst->instatantImps==1) ) 
										{     
										      
										         if(($UI__Rgst->instatantImps==1))
										                 include_once("autoTxn-2.php");    
                                                else if( ($RstUxd1Auto->automaual==1) && ($Pay2alllBal>$_POST['amount']) )
                                                    include_once("autoTxn-2.php");
                                                else
                                                {
                                                    $stmt=$conn->prepare("insert into UI__TxnFailUsers(custId,Tdate,amt,type,accno,ifsc,holder,cdId,impnft,Byfrom) values(:custId,:Tdate,:amt,:type,:accno,:ifsc,:holder,:cdId,1,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();    
                                                }    
										}
										else 
										{   
										       
                                                $ch = curl_init('https://grappay.com/api/telecom/v1/check-balance?api_token=HdL32mhRkJU7rbUwmXIvRHGqP53Bkwg8FRRWpZ7MNfryg35EiX5ESyJrk7KB');                                             
                                                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");                                                                     
                                                curl_setopt($ch, CURLOPT_POSTFIELDS, $access_token);                                                                  
                                                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
                                                curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
                                                'x-tera-tenant-region: IN', 
                                                'Content-Type: application/json', 
                                                'Content-Length: ' . strlen($access_token))                                                                       
                                                );       																		 
                                                $response = curl_exec($ch); 
                                                $grappay1 = json_decode($response);   
                                                
                                                $normal_balancebal = (int)$grappay1->balance->normal_balance;
                                                
                                                if( ($RstUxd1Auto->automaual==1)  && ($normal_balancebal>$_POST['amount']) )
										            include_once("autoTxn.php");  
										        else 
										        {  
                                                    $stmt=$conn->prepare("insert into UI__TxnFailUsersPay2(custId,Tdate,amt,type,accno,ifsc,holder,cdId,impnft,Byfrom) values(:custId,:Tdate,:amt,:type,:accno,:ifsc,:holder,:cdId,1,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();  
										        } 
										}
										
										$PAYWAllet =  GetBalance();  
										$stmt=$conn->prepare("select id from UI__Rgst  where  cuurentId=:cuurentId    ");   
										$stmt->bindValue(':cuurentId',   $_SESSION['userId'] , PDO::PARAM_STR);  
										$stmt->execute(); 
										$UIid = $stmt->fetch(PDO::FETCH_OBJ);   
										
										$amount = password_hash(($PAYWAllet),PASSWORD_DEFAULT);  
										$stmt =  $conn->prepare("update _pkCc__ set bl1=:bl1,tm=:tm where Uxd=:Uxd "); 
										$stmt->bindValue(':bl1', $amount, PDO::PARAM_STR); 
										$stmt->bindValue(':tm', date("d-M-Y H:i"), PDO::PARAM_STR); 
										$stmt->bindValue(':Uxd', $UIid->id, PDO::PARAM_STR);  
										$stmt->execute();   

										
										$stmt=$conn->prepare("update    UI__LastBal set  LastBal=:LastBal  where  custId=:custId");   
										$stmt->bindValue(':LastBal',  ($UI__LastBal->LastBal-$_POST['amount']) , PDO::PARAM_STR);  
										$stmt->bindValue(':custId',  $_SESSION['userId'] , PDO::PARAM_STR);  
										$stmt->execute();   
										
										$stmt=$conn->prepare("select id from moneytransfer  order by id desc  ");     
										$stmt->execute(); 
										$LastId = $stmt->fetch(PDO::FETCH_OBJ);   
										
										 
										$stmt=$conn->prepare("update   moneytransfer    set  DebitCredit_id=:DebitCredit_id  where  id=:id");   
										$stmt->bindValue(':DebitCredit_id', $_SESSION['LastIntId'] , PDO::PARAM_STR);   
										$stmt->bindValue(':id',  $LastId->id , PDO::PARAM_STR);   
										$stmt->execute(); 
										
										if($status==1)
										    $ary['reVal'] =  $_SESSION['LastIntId']."_";  
										else
										    $ary['reVal'] =  $_SESSION['LastIntId'];  
										    
										    
                                        $title = "Withdrawl";
                                        $message = "Withdrawl of Rs ".$_POST['amount']."/-";
                                        notifc($token,$title,$message);   
                                        
                                        echo json_encode($ary);  
										die;   
									}
									   
									
									if( ($Resp1['rechargeStatus']!='Fail')  && ($dpLimit<=$mlimit) )
									{   
									
									}else if($dpLimit>$mlimit) 
								   {      
									    $ary['Sccuecc']  = 0;
                                        $ary['message']  =  "Your daily  transaction limit  of $mlimit is over ";    
                                        echo json_encode($ary);  
										die;   
								   }
							    
							   
						   } ////section 1 end************************************** 
						   else if(($_POST['mode']==2) && ($directxfer==0) ) ////// ************* IMPS MANUAL TXN*************// section 2 start
						   {    	     
						    
							$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,pay2All2) 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,:pay2All2)");            
										$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->bindValue(':pay2All2', $pay2All2, 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);    
			
										///     
										if($deduction>0)
										{
										$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(); 
										
										 
										$ary['Sccuecc']  = 1;
                                        $ary['message']  =  "Your Amount has been proceed by NEFT";
                                        
										
											
										$subject = "Money Transfer  On ".date("H:i");  
										$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); 
                                        
                                        {

										// failter start....  
										$stmt=$conn->prepare("insert into UI__TxnFailUsers (custId,Tdate,amt,type,accno,ifsc,holder,cdId,impnft,Byfrom) values(:custId,:Tdate,:amt,:type,:accno,:ifsc,:holder,:cdId,1,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();  
										
										
        											
                                        $stmt=$conn->prepare("update    UI__LastBal set  LastBal=:LastBal  where  custId=:custId");   
                                        $stmt->bindValue(':LastBal',  ($UI__LastBal->LastBal-$_POST['amount']) , PDO::PARAM_STR);  
                                        $stmt->bindValue(':custId',  $_SESSION['userId'] , PDO::PARAM_STR);  
                                        $stmt->execute();  
										 
											
										$subject = "NEFT BY ".$_SESSION['userId']."  On ".date("H:i");  
										$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 = "Money Transfered by  ".$_SESSION['userId']."  On ".date("H:i");  
										$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();   
										
										
										$stmt=$conn->prepare("select id from moneytransfer  order by id desc  ");     
										$stmt->execute(); 
										$LastId = $stmt->fetch(PDO::FETCH_OBJ);   
										
										 
										$stmt=$conn->prepare("update   moneytransfer    set  DebitCredit_id=:DebitCredit_id  where  id=:id");   
										$stmt->bindValue(':DebitCredit_id', $_SESSION['LastIntId'] , PDO::PARAM_STR);   
										$stmt->bindValue(':id',  $LastId->id , PDO::PARAM_STR);   
										$stmt->execute();     
										
										
											    
                                        $title = "Withdrawl";
                                        $message = "Withdrawl of Rs ".$_POST['amount']."/-";
                                        notifc($token,$title,$message);   
                                        
								    	$ary['reVal'] =  $_SESSION['LastIntId'];  
                                        echo json_encode($ary);  
										die;   
							    	
							   }else if($dpLimit>$mlimit) 
							   {       
                                    $ary['message']  =  "Your daily  transaction limit  of $mlimit is over ";      
					           }
						   }	//////// section 2 end *********************						   
						   else if( ($_POST['mode']==1)) /// *************************************  NEFT TXN..HERE ********************/// section 3 start
						   {
						       
						       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);  
                                 
                                if($deduction>0)
										{
                                $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",$_SESSION['userId']);    
                                
                                
                                $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",$_SESSION['userId']);    
                                
                                
                                $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['topSuc'] = 1;
                                
								$ary['Sccuecc']  = 1;
								$ary['message']  = "Your Amount has been proceed by NEFT";
							
                                
                                
                                    
                                $subject = "Money Transfer  BY ".$_SESSION['userId']."  On ".date("H:i");  
                                $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();  
                                
                                
                                	
                                $stmt=$conn->prepare("update    UI__LastBal set  LastBal=:LastBal  where  custId=:custId");   
                                $stmt->bindValue(':LastBal',  ($UI__LastBal->LastBal-$_POST['amount']) , PDO::PARAM_STR);  
                                $stmt->bindValue(':custId',  $_SESSION['userId'] , PDO::PARAM_STR);  
                                $stmt->execute();  
                                 
                                    
                                $subject = "NEFT BY ".$_SESSION['userId']."  On ".date("H:i");  
                                $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 = "Money Tranfered BY ".$_SESSION['userId']. "  On ".date("H:i");  
                                $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();  
                                    
                                    
                        	    
                                $title = "Withdrawl";
                                $message = "Withdrawl of Rs ".$_POST['amount']."/-";
                                notifc($token,$title,$message);       
                                     
                                $ary['reVal'] =  $_SESSION['LastIntId'];  
                                echo json_encode($ary);  
                                die;   
                             
                                }else 
                                    $ary['message']  = "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);  
                                 
                                if($deduction>0)
								{
                                $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(); 
                                
                                
                                
                                $stmt=$conn->prepare("insert into UI__WithDrawForD(userid,Tdate,amt,orgAmt,order_id,bank_remark,status,accept,payout) values(:userid,:Tdate,:amt,:orgAmt,:order_id,:bank_remark,:status,:accept,1)"); 
                                $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', "NA", PDO::PARAM_STR); 
                                $stmt->bindValue(':status', 0 , PDO::PARAM_STR); 
                                $stmt->bindValue(':accept', 1 , PDO::PARAM_STR);      
                                $stmt->execute();   
                                LvBalForD($_SESSION['userId'],($_POST['amount']),2,"NEFT",$_POST['amount']);
                                
                                
                                	   
    							// 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();  

                             
                                $_SESSION['topSuc'] = 1;
                                
                            	$ary['Sccuecc']  = 1;
								$ary['message']  = "Your Amount has been proceed by NEFT";
							
                                
                                
                                    
                                $subject = "Money Transfer  On ".$SITE_NAME." On ".date("H:i");    
                                $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." On ".date("H:i");    
                                $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();  
                                
                                 
                              
                                $title = "Withdrawl";
                                $message = "Withdrawl of Rs ".$_POST['amount']."/-";
                                notifc($token,$title,$message);        

                                    
                                $ary['reVal'] =  $_SESSION['LastIntId'];  
                                echo json_encode($ary);  
                                die;   
                                }else
                                   $ary['message']  = "Your todays remaining limit  is Rs ".$Blimit;  
                                    
		
								}/// for D  end									  
                             
                           }    ////////// section 3 end
                    }else
                        $ary['message']  =  "Fail: Error No: 303 Contact Customer Care: 805 050 1222";   
                                        
                                        
                        $ary['Sccuecc']  = 0; 
                        echo json_encode($ary);
                        die;                  
                                       
        }/// enf of submit
                     
                        
                            
            include_once("../view/dashboard/mt3.php");
?>