<?php
	include_once('../config.php');      
	include_once(ABS_PATH.'/custom_function/default.php'); 
    if(!isset($_SESSION['userId']))
    { 
         header("Location: ../");
         die;
    }   
                
                                   
                $stmt=$conn->prepare("select * from  UI__AddAccount  where custId=:cuurentId");    
                $stmt->bindValue(':cuurentId',  $_SESSION['userId'], PDO::PARAM_STR);     
                $stmt->execute(); 
                $Result = $stmt->fetchAll(PDO::FETCH_OBJ);      
                 
	
	            if(isset($_REQUEST['clearAll']))
	            { 
                    unset($_SESSION['TpMsg']);
                    unset($_SESSION['deleteId']);  
                    unset($_SESSION['deletMsg']);
                    header("Location: DeleteMAccount.php");
                    die;  
	            }
	            
	            if(isset($_REQUEST['DelId']))
	            {
                      
                    $stmt=$conn->prepare("SELECT phm FROM UI__Rgst WHERE   cuurentId=:cuurentId ");   
                    $stmt->bindValue(':cuurentId', $_SESSION['userId']  , PDO::PARAM_STR);
                    $stmt->execute(); 
                    $CustData = $stmt->fetch(PDO::FETCH_OBJ); 
                    $_SESSION['OtpLogin'] =  rand(11234,23344);
                    $CMB = $_SESSION['OtpLogin'];
                    $mob = $CustData->phm;
                    $msg = urlencode(''.$CMB.' is your mobile verification one time password to proceed on DAILYPAY. It is valid for 5 minitus.'); 
                    $URL  = 'http://mobicomm.dove-sms.com//submitsms.jsp?user=DailyPAY&key=d92eabc025XX&mobile=+91'.$mob.'&message='.$msg.'&senderid=DAYPAY&accusage=1&entityid=1201169824017740929&tempid=1207169907610629409';
                    
                    $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);  
                    
                    $_SESSION['deleteId'] = $_REQUEST['DelId']; 
                    $_SESSION['TpMsg'] = "Otp has been sent on your resgitered mobile no";  
                    header("Location: DeleteMAccount.php");
                    die;
	            } 
                 
                if(isset($_POST['DelOtp']))
                {    
                    if($_POST['enterOtp']==$_SESSION['OtpLogin']) 
                    { 
                        $stmt=$conn->prepare("delete from   UI__AddAccount  where  id=:id  ");   
                        $stmt->bindValue(':id',  $_SESSION['deleteId'] , PDO::PARAM_STR);  
                        $stmt->execute();  
                        unset($_SESSION['TpMsg']);
                        unset($_SESSION['deleteId']);
                        unset($_SESSION['deletMsg']);
                    }else
                        $_SESSION['deletMsg'] = "Please enter correct OTP";
                     
                    header("Location: DeleteMAccount.php");
                    die;
                }  

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