<?php
	include_once('../config.php');   
    
  
          
    if(!isset($_SESSION['userId']))
    { 
         header("Location: ../");
         die;
    }
     
    if(isset($_POST['submitForm']))
    {   
                    
                if($_FILES['adharcard']['name']!='')
                {
                   
                    unlink(BASEABS_PATH.'/uploads/fundReq/'.$_POST['adharcardhidden']);   
                    $ext = explode(".",$_FILES['adharcard']['name']);//explode file name from dot(.)   
                    $Fname =  substr(md5(uniqid()),26).".".end($ext);  
                    $target_path = BASEABS_PATH."/uploads/fundReq/".$Fname;//set the target path with a new name of image 
                    move_uploaded_file($_FILES['adharcard']['tmp_name'], $target_path); 
                }
                
                 if($_FILES['adhaback']['name']!='')
                {
                   
                    unlink(BASEABS_PATH.'/uploads/fundReq/'.$_POST['adharcardbackhidden']);   
                    $ext = explode(".",$_FILES['adhaback']['name']);//explode file name from dot(.)   
                    $Fname1 =  substr(md5(uniqid()),26).".".end($ext);  
                    $target_path = BASEABS_PATH."/uploads/fundReq/".$Fname1;//set the target path with a new name of image 
                    move_uploaded_file($_FILES['adhaback']['tmp_name'], $target_path); 
                }
            
             
                    
                    $stmt=$conn->prepare("update  UI__Rgst set  adharcard=:adharcard,adhaback=:adhaback where custId=:custId ");    
                    $stmt->bindValue(':custId', $_SESSION['userCustId'] , PDO::PARAM_STR);  
                    $stmt->bindValue(':adharcard', $Fname , PDO::PARAM_STR); 
                    $stmt->bindValue(':adhaback', $Fname1 , PDO::PARAM_STR); 
                    $stmt->execute();   
                    $_SESSION['Regis'] = "Adhar Updated Successfully";
                    header("Location: kyc.php");  
             
    }         
     
             
            $stmt=$conn->prepare("select  *   from  UI__Rgst where custId =:custId ");   
            $stmt->bindValue(':custId', $_SESSION['userCustId'] , PDO::PARAM_STR);  
            $stmt->execute(); 
            $FResult = $stmt->fetch(PDO::FETCH_OBJ); 
            
            if($FResult->ahdf==1)
                $fstatus = "Approved";
            else if($FResult->ahdf==2)     
                $fstatus = "Reject";
            else    
                $fstatus = "Pending";
                
                
            
            if($FResult->ahdb==1)
                $bstatus = "Approved";
            else if($FResult->ahdb==2)     
                $bstatus = "Reject";
            else    
                $bstatus = "Pending";
               
                
        $Dtm = MASTER_ROOTPATH.'/registration/kycUpload.php?UserId='.$_SESSION['userId'];
                    
include_once("../view/dashboard/kyc.php");
?>