<?php

class UserInfo extends CI_Model
{
    public $username;
    public $pass;
    public $fullName;
    public $contactInfo;
    public $address;
    public $userlvl;
    public $branch;
    public $editDate;
    public $creationDate;

    public function __construct()
	{
		parent::__construct();

		$this->load->database();
    }

    public function verifyUser($username, $userPass)
    {
        $pass = md5(substr_replace($userPass, $this->config->item('encryption_key'), 1, 0));

        $this->db->select("username, fullName, userlvl, branch");
        $result = $this->db->get_where("userinfo", array("username"=>$username, "pass"=>$pass));

        if($result->num_rows() == 1)
        {
            foreach($result->result() as $row)
            {
                $this->username = $row->username;
                $this->fullName = $row->fullName;
                $this->userlvl = $row->userlvl;
                $this->branch = $row->branch;
            }

            return true;
        }
        else
            return false;
    }
}