<?php

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

class Epos_Model extends MY_Model {

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

    public function getUser($username, $password, $userID = null, $employeeId = null) {
        $this->db->select('U.id,U.username,U.group, U.onapp, E.first_name ,E.last_name,E.manager');
        $this->db->from('user U');
        $this->db->join('employee E', 'U.employee=E.id', 'left');
        if ($userID && $employeeId) {
            $this->db->where(array('U.id' => $userID, 'U.username' => $username, 'U.password' => md5($password), 'E.id' => $employeeId));
        } else {
            $this->db->where(array('U.username' => $username, 'U.password' => md5($password)));
        }
        $thisUser = $this->db->get()->row();
        return $thisUser;
    }

    public function eposUserLogs($data, $id = null) {
        $this->_table_name = 'userlogtime';
        $this->_primary_key = 'id';
        return $this->save($data, $id);
    }

}
