<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of customerRegistrationmodel
 *
 * @author BusyMan
 */
class UserRegistrationModel extends CI_Model { 

    //put your code here
    private $_tbl_admin = 'tbl_admin';
     private $_tbl_user = 'tbl_user';

    public function saveAccessInfo($datax) {
        $datax['password']=sha1(md5($datax['password']));
        $this->db->insert($this->_tbl_admin, $datax);
        return $this->db->insert_id();
    }

    public function saveUserInfo($data) {
        $data['joiningdate']=date('Y-m-d',strtotime($data['joiningdate']));
        $this->db->insert($this->_tbl_user, $data);
        return $this->db->insert_id();
    }

    public function getUsernameById($data){
        $query=$this->db->get_where($this->_tbl_admin,array('admin_level'=>$data['admin_level'],'employeeId'=>$data['employeeId']));
        $result=$query->row_array();
        if(!empty($result)){
            return $result;
        }
    }

    public function changePassword($data){
        // $this->db->update($this->_tbl_admin,$data,array('userName'=>$data['userName']));
        // return $this->db->affected_rows();
        // $this->db->set('password',$data['password'])
        //         ->where('userName',$data['userName'])
        //         ->update('tbl_admin');
        // return $this->db->affected_rows();
    }
}