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

class m_login extends CI_Model{

	// 생성자, 해당 모델이 생성될때 항상 실행되는 초기화작업
	function __construct(){
		parent::__construct();

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

    #---------------------------------------------------------------------------
    # PURPOSE :	어드민 로그인 실핼
    # CREATE  :	2018-02-18
    #---------------------------------------------------------------------------
	function login_proc($req_data){

	    # request
        $user_id    = $req_data['user_id'];
	    $user_pwd   = $req_data['user_pwd'];

        $sql1 = "select idx, user_id, user_name, last_login_date, '0' as member_group_idx from admin where is_del = 'N' and user_id ='".$user_id."' and user_pwd = MD5('".$user_pwd."')";
        $res1 = $this->db->query($sql1);
        $row1 = $res1->row();

        $array = json_decode(json_encode($row1), true);

        return $array;
    }

    #---------------------------------------------------------------------------
    # PURPOSE :	마지막 로그인 업데이트
    # CREATE  :	2018-02-18
    #---------------------------------------------------------------------------
	function last_login_update($req_data){
	    # request
	    $idx            = $req_data['idx'];
	    $tb             = $req_data['tb'];

        $now_date       = date("Y-m-d H:i:s");

        $update_data = array();
        $update_data['last_login_date'] = $now_date;

        $this->db->where('idx', $idx);
        $row = $this->db->update($tb, $update_data);

        return $row;

    }

    #---------------------------------------------------------------------------
    # PURPOSE :	파트너 어드민 로그인 실핼
    # CREATE  :	2018-02-28
    #---------------------------------------------------------------------------
	function partner_login_proc($req_data){
	    # request
        $user_id            = $req_data['user_id'];
	    $user_pwd           = $req_data['user_pwd'];

        $sql1 = "select idx, partner_id as user_id, partner_name as user_name, last_login_date, member_group_idx from partner where is_del = 'N' and partner_id ='".$user_id."' and partner_pwd = MD5('".$user_pwd."')";
        $res1 = $this->db->query($sql1);
        $row1 = $res1->row();

        $array = json_decode(json_encode($row1), true);

        return $array;
    }





}
?>
