<?php
	include_once('../config.php');   
    
  
          
    if(!isset($_SESSION['userId']))
    { 
         header("Location: ../");
         die;
    }
    
    if(isset($_POST['submitForm']))
    {     
         
            if($_FILES['payment_slip']['name']!='') 
            {
            $ext = explode(".",$_FILES['payment_slip']['name']);//explode file name from dot(.)   
            $Fname =  substr(md5(uniqid()),26).".".end($ext);  
            $target_path = ABS_PATH."/uploads/fundReq/".$Fname;//set the target path with a new name of image 
            move_uploaded_file($_FILES['payment_slip']['tmp_name'], $target_path);   
            }else
                $Fname = "NA";
                
           
            if($_POST['TRC']!='')
                $TRC = "TEST TRC";
            else
                $TRC  = $_POST['TRC'];
                
                  
                  
           /* if(strlen($_POST['Bnumber'])>4) 
                $Bnumber = substr($_POST['Bnumber'], -4);   
            else*/
                $Bnumber =  $_POST['Bnumber'];
                      
                
                function clean($string) 
                {
                    $string = str_replace(' ', '_', $string); // Replaces all spaces with hyphens. 
                    return preg_replace('/[^A-Za-z0-9\-]/', ' ', $string); // Removes special chars.
                }


            $_POST['Fcity'] = clean($_POST['Fcity']);
            $_POST['address'] = clean($_POST['address']);
            $_POST['AccHoldernumber'] = clean($_POST['AccHoldernumber']);
            
            $stmt=$conn->prepare("update  UI__Rgst set UserPin=:UserPin, PinDis=:PinDis,pincode=:pincode,city=:city,address=:address,nm=:nm,eml=:eml,accHolderNm=:accHolderNm,Bnumber=:Bnumber,Bname=:Bname,Bifsc=:Bifsc,Bbranch=:Bbranch,paymentSlip=:paymentSlip,UPI=:UPI  where custId=:custId ");   
            $stmt->bindValue(':UserPin', $_POST['UserPin'] , PDO::PARAM_STR); 
            $stmt->bindValue(':PinDis', $_POST['PinDis'] , PDO::PARAM_STR); 
            $stmt->bindValue(':pincode', $_POST['pincode'] , PDO::PARAM_STR); 
            $stmt->bindValue(':city', $_POST['Fcity'] , PDO::PARAM_STR); 
            $stmt->bindValue(':address', $_POST['address'] , PDO::PARAM_STR); 
            $stmt->bindValue(':nm', $_POST['Fname'] , PDO::PARAM_STR); 
            $stmt->bindValue(':nm', $_POST['Fname'] , PDO::PARAM_STR);  
            $stmt->bindValue(':eml', $_POST['Email'] , PDO::PARAM_STR);  
            $stmt->bindValue(':custId', $_SESSION['userCustId'] , PDO::PARAM_STR); 
            $stmt->bindValue(':accHolderNm', $_POST['AccHoldernumber']  , PDO::PARAM_STR); 
            $stmt->bindValue(':Bnumber', $Bnumber  , PDO::PARAM_STR); 
            $stmt->bindValue(':Bname', $_POST['Bname']  , PDO::PARAM_STR); 
            $stmt->bindValue(':Bifsc', $_POST['Bifsc']  , PDO::PARAM_STR); 
            $stmt->bindValue(':Bbranch', $_POST['Bbranch']  , PDO::PARAM_STR); 
            $stmt->bindValue(':paymentSlip', $Fname , PDO::PARAM_STR);     
            $stmt->bindValue(':UPI', $_POST['UPI'] , PDO::PARAM_STR);  
              
            $stmt->execute();       
            
            $_SESSION['Regis'] = "Profile Updated";
            header("Location: profile.php");  
            die;
    }         
     
             
          
            $stmt=$conn->prepare("select  *   from  UI__Rgst where cuurentId =:cuurentId ");   
            $stmt->bindValue(':cuurentId', $_SESSION['userId'] , PDO::PARAM_STR);  
            $stmt->execute(); 
            $FResult = $stmt->fetch(PDO::FETCH_OBJ);  
               
               
            $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 * from   UI__AdharVeri where custId=:cuurentId");    
            $stmt->bindValue(':cuurentId',  $_SESSION['userId'], PDO::PARAM_STR);     
            $stmt->execute(); 
            $AdharVer = $stmt->rowCount();
            $UI__AdharVeri = $stmt->fetch(PDO::FETCH_OBJ);  
            
             
            
            if( ($PanVer>0) &&  ($AdharVer>0))
                $evar = 1;    
           
                
include_once("../view/dashboard/reviews.php");
?>