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

class Vectra extends CI_Controller{ 	 

	function __construct(){ 
		parent::__construct();
		$this->load->helper('userlogin');
		checkIfUserLoggedIn($this->session->userdata($this->config->item('sess_prefix').'sess_user_id'));
		$this->data['user_details']=$this->User_mdl->user_details($this->session->userdata($this->config->item('sess_prefix').'sess_user_id'));
		$this->data['user_accounts_listing']=$this->User_mdl->user_accounts_listing($this->data['user_details']->user_id);
 		$this->data['title']='Vectra Transfer Money';
 	}
	
	public function index(){
		$userId = $this->session->userdata($this->config->item('sess_prefix').'sess_user_id');
		$this->data['my_bank_accounts_listing']=$this->User_mdl->my_bank_accounts_listing($userId);
		$this->data['unique_sent_account_no']=$this->User_mdl->unique_sent_account_no($userId);
		$this->data['page_name']='Vectra Transfer Money';
		$this->data['active_class']='transfer_money';
		$this->load->view('Frontend/includes/header',$this->data);
		$this->load->view('Frontend/vectra_trans_money/send',$this->data);
		$this->load->view('Frontend/includes/footer',$this->data);
	}
	
	public function history(){	
		$this->data['page_name']='All History';
		$this->data['active_class']='vectra_history';
		$this->data['vectra_history_listing']=$this->User_mdl->vectra_history_listing($this->session->userdata($this->config->item('sess_prefix').'sess_user_id'));
		$this->load->view('Frontend/includes/header',$this->data);
		$this->load->view('Frontend/vectra_trans_money/history',$this->data);
		$this->load->view('Frontend/includes/footer',$this->data);
	}
	
	public function generateRandomString($length = 10) {
		$characters = '123456789ABCDEFGHIJKLMNPQRSTUVWXYZ';
		$charactersLength = strlen($characters);
		$randomString = '';
		for ($i = 0; $i < $length; $i++) {
			$randomString .= $characters[rand(0, $charactersLength - 1)];
		}
		return $randomString;
	}
	
	public function save_trans_entry(){
		$txn_id = $this->generateRandomString();
		$userId = $this->session->userdata($this->config->item('sess_prefix').'sess_user_id');
		$this->User_mdl->victra_transfer_money_entry($userId,$txn_id);
	}
	
}