<?php 

class M_log extends CI_Model{	

    

    function __construct() {

        parent::__construct();

    }

    

    function user_nik(){

        return $this->session->userdata('sess_nik');

    }

    

    function data_login($data){

        $sql = "SELECT u.*,um.nama nama_um, um.kode kode_um, um.id_unit_misioner id_um FROM tb_user u 

                LEFT JOIN tb_unit_misioner um ON u.unit_misioner = um.id_unit_misioner

                WHERE (u.username = '$data[username]' || u.email = '$data[username]') AND u.password = '$data[password]' AND u.valid = 1  AND u.is_deleted = 0 ";

        return $this->db->query($sql);

    }
    function insert_log($data){
        $sql = "INSERT INTO `tb_log`
                        (`kode_user`, `sebagai`, `created_at`) 
                VALUES  ('$data[kode_user]','$data[sebagai]',NOW())";
        return $this->db->query($sql);
    }

}